fix(newsletter): render _underscore italics_ in issue bodies
issueToMarkdown wraps each issue's vibe in _underscores_, but the in-app markdown renderer only understood *asterisk* emphasis — so every published archive issue showed LITERAL underscores around its intro line (both in our reader and here). Added the underscore form to the tokenizer. Verified on the live issue-5 naddr: the vibe now renders as <em> with no literal underscores.
This commit is contained in:
parent
261e4c9115
commit
565fdb9211
1 changed files with 12 additions and 7 deletions
|
|
@ -29,8 +29,11 @@ function renderMarkdown(md: string) {
|
|||
|
||||
const renderInline = (text: string): React.ReactNode[] => {
|
||||
const nodes: React.ReactNode[] = [];
|
||||
// Tokenise **bold**, *italic*, and [label](url) / bare http(s) links.
|
||||
const regex = /(\*\*([^*]+)\*\*)|(\*([^*]+)\*)|(\[([^\]]+)\]\((https?:\/\/[^\s)]+)\))|(https?:\/\/[^\s]+)/g;
|
||||
// Tokenise **bold**, *italic*, _italic_ (underscore form — issueToMarkdown
|
||||
// wraps the vibe in underscores, which used to render as LITERAL underscores
|
||||
// in this reader), [label](url) and bare http(s) links.
|
||||
const regex =
|
||||
/(\*\*([^*]+)\*\*)|(\*([^*]+)\*)|(_([^_]+)_)|(\[([^\]]+)\]\((https?:\/\/[^\s)]+)\))|(https?:\/\/[^\s]+)/g;
|
||||
let last = 0;
|
||||
let m: RegExpExecArray | null;
|
||||
let i = 0;
|
||||
|
|
@ -41,15 +44,17 @@ function renderMarkdown(md: string) {
|
|||
} else if (m[3]) {
|
||||
nodes.push(<em key={i++} className="italic">{m[4]}</em>);
|
||||
} else if (m[5]) {
|
||||
nodes.push(<em key={i++} className="italic">{m[6]}</em>);
|
||||
} else if (m[7]) {
|
||||
nodes.push(
|
||||
<a key={i++} href={m[7]} target="_blank" rel="noopener noreferrer" className="text-[#ccff00] underline underline-offset-2 hover:opacity-80">
|
||||
{m[6]}
|
||||
<a key={i++} href={m[9]} target="_blank" rel="noopener noreferrer" className="text-[#ccff00] underline underline-offset-2 hover:opacity-80">
|
||||
{m[8]}
|
||||
</a>,
|
||||
);
|
||||
} else if (m[8]) {
|
||||
} else if (m[10]) {
|
||||
nodes.push(
|
||||
<a key={i++} href={m[8]} target="_blank" rel="noopener noreferrer" className="text-[#ccff00] underline underline-offset-2 hover:opacity-80 break-all">
|
||||
{m[8]}
|
||||
<a key={i++} href={m[10]} target="_blank" rel="noopener noreferrer" className="text-[#ccff00] underline underline-offset-2 hover:opacity-80 break-all">
|
||||
{m[10]}
|
||||
</a>,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue