## High-level Approach (How)
The goal of this project is to enable rich text formatting in Wikifunctions' output, specifically allowing basic HTML tags such as **bold**, //italic//, and underline, as well as hyperlinks. This will enhance the usability and expressiveness of the content generated by Wikifunctions.
### **Approach Overview:**
1. **Define User-Relevant Outcome**: The first step is to determine a clear user-facing result for this Proof of Concept (POC). This includes defining a sentence or such with specific text styles like **bold**, //italic//, underline, and incorporating links in the outputs that are relevant to Wikipedia users.
Can we define a user-relevant end result that we want this POC to deliver?
❓**Decision on output**: TBD
2. **Z89 Function Model**: We will design a function model for [[ https://www.wikifunctions.org/wiki/Z89 | Z89/HTML Fragment ]] will return HTML strings wrapped in a Z89 type. They will be rendered on both the Wikifunctions platform and within Wikipedia articles.
3. **Sanitization**: To avoid the risks of unsafe HTML, we will sanitize all generated HTML at the PHP level using the MediaWiki Sanitizer. This ensures that only allowed HTML tags are used. This step will prevent malicious code from being included in outputs.
Open for discussion is still where people can link to. Can people link to any website (risk of inappropriate links) or only to (internal) Wiki pages? And how about links in [[ https://www.wikidata.org/wiki/Q42 | Wikidata ]] items (in Identifiers for example)?
❓**Decision on links**: TBD
4. **Frontend Rendering in Wikifunctions**: A dedicated frontend component will be created to safely render [[ https://www.wikifunctions.org/wiki/Z89 | Z89/HTML Fragment ]] in the Wikifunctions interface. This component will be similar to some existing components, but tailored for HTML output.
5. **Rendering in Wikipedia Articles**: After ensuring the Z89 HTML output works within Wikifunctions, we will modify the system so that these HTML fragments are properly rendered in Wikipedia articles. This will require collaboration with the Content Transform Team, particularly for Parsoid, which is responsible for transforming content between wikitext and HTML.
6. **[Optional] User Guidance and Documentation**: Clear documentation and UI hints will be provided to guide users on how to apply rich text formatting using HTML tags. The documentation will help them understand which tags are supported and how to use them effectively.
7. **Testing and Validation**: Thorough testing will be conducted to ensure the functionality works as expected, including security testing (to prevent XSS attacks), usability testing, and performance testing (to ensure rendering doesn't affect page load times).
### **Assumptions**
* Users are familiar with basic HTML tags for text formatting.
* Out of scope for our team should be converting the HTML to Wikitext:
* `<strong>Bold</strong>` => '''Bold'''
* `<em>Italic</em>` => ''Italic''
* `<u>underline</u>` => <u>underline</u>
### **Acceptance Criteria**
* **Formatted Text Output:**
Functions must support outputting text that includes basic formatting—**bold** (`<strong>` or `<b>`), //italic// (`<em>` or `<i>`), and underline (`<u>`)—and ensure this formatting is correctly displayed both within Wikifunctions and when transcluded into Wikipedia articles. The system should allow for both semantic (`<strong>`, `<em>`) and presentational (`<b>`, `<i>`) tags, leaving the choice to the community. But we should probably support whatever the MediaWiki Sanitizer allows us to insert.
* **Hyperlink Support:**
Users can include functional hyperlinks (`<a href="...">`) in Wikifunctions string outputs.
* **HTML Sanitization:**
Any HTML content in the function output must be properly sanitized to prevent the injection of malicious or unsafe code, ensuring the safety of both Wikifunctions and Wikipedia.
* **[Stretch Goal] User Guidance for Rich Text:**
Users must be provided with clear instructions, UI prompts, or documentation that guides them on how to include rich text formatting in their function outputs.