US-YW12: Handle yWriter Markup Conversion
Novel writing app that bridges outlining and drafting. Built with Rust
Status: Beta
Brought to you by:
smithandweb
Originally created by: smith-and-web
As a yWriter user,
I want to have my text formatting preserved,
So that my prose displays correctly in Kindling.
Parent Epic: [#123]
yWriter uses BBCode-style markup in <SceneContent>:
| yWriter | Meaning | HTML | TipTap |
|---|---|---|---|
[i]...[/i] |
Italic | <em> |
Italic mark |
[b]...[/b] |
Bold | <strong> |
Bold mark |
[s]...[/s] |
Strikethrough | <s> |
Strike mark |
[u]...[/u] |
Underline | <u> |
Underline (if supported) |
| Pattern | Meaning | Handling |
|---|---|---|
/* ... */ |
Author comment | Preserve as note or strip |
> ... |
Quotation marker | Convert to blockquote or preserve |
--- |
Scene break | Convert to horizontal rule |
[note]...[/note] |
Inline note | Preserve or convert to comment |
Some yWriter files may contain:
&, <, etc.)“ for smart quotes)Input (yWriter):
Sarah stared at the letter. [i]This can't be real[/i], she thought.
"You [b]knew[/b]," she said, her voice barely a whisper.
/* TODO: Add more tension here */
John's face went pale. He [s]reached for his coffee[/s] stood up abruptly.
Output (HTML for TipTap):
<p>Sarah stared at the letter. <em>This can't be real</em>, she thought.</p>
<p>"You <strong>knew</strong>," she said, her voice barely a whisper.</p>
<p>John's face went pale. He <s>reached for his coffee</s> stood up abruptly.</p>
fn convert_ywriter_markup(text: &str) -> String {
text
.replace("[i]", "<em>")
.replace("[/i]", "</em>")
.replace("[b]", "<strong>")
.replace("[/b]", "</strong>")
.replace("[s]", "<s>")
.replace("[/s]", "</s>")
// Handle unclosed tags gracefully
// Strip or preserve comments based on config
}
[i]...[/i] converts to italics[b]...[/b] converts to bold[s]...[/s] converts to strikethrough[u]...[/u] converts to underline or stripped (configurable)[i]italic [b]bold italic[/b][/i]/* ... */ optionally preserved or stripped[i]start of italic without [/i][i][b]text[/i][/b][i]first para\n\nsecond para[/i][b][/b] (strip completely)\[not a tag\] (rare but possible)
Originally posted by: smith-and-web
Implemented in PR [#140]. yWriter markup ([b]bold[/b], [i]italic[/i]) is converted to HTML (, ) during import.
Related
Tickets:
#140Ticket changed by: smith-and-web