File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,21 +180,26 @@ proc toStr*(self: PDInlineLink): string =
180180 else :
181181 unreachable (& " PDInlineLink: { self.t= } " )
182182
183+ proc escapeBar * (text: string ): string =
184+ if text.startsWith ('|' ) or text.endsWith ('|' ):
185+ return " |" & text & " |"
186+ return text
187+
183188proc toStr * (self: PDInlineCode ): string =
184189 let (attr, text) = self.c
185190 let lang = if attr.classes.len > 0 : & " (code:{ attr.classes[0 ]} ) " else : " "
186- & " `{ text} `{ lang} "
191+ & " `{ escapeBar ( text) } `{ lang} "
187192
188193proc toStr * (self: PDInlineEmph ): string =
189194 let symbol = symbols[self.t]
190- defer : result = & " { symbol} { result } { symbol} "
195+ defer : result = & " { symbol} { escapeBar ( result ) } { symbol} "
191196 result = self.c.toStr ()
192197 if result [^ 1 ] == '\n ' :
193198 return result [0 ..< ^ 1 ]
194199
195200proc rawEmbed * (s: string , lang: string ): string =
196201 if s.find ('\n ' ) < 0 :
197- return & " `| { s} |`(embed:{ lang} ) "
202+ return & " `|{ s} |`(embed:{ lang} ) "
198203 else :
199204 return joinWithNewline (" @embed " & lang, s.strip (), " @end" )
200205
You can’t perform that action at this time.
0 commit comments