matusnovak / doxybook

Generate GitBook, VuePress, Docsify, or MkDocs out of Doxygen XML output
https://matusnovak.github.io/doxybook/
MIT License
32 stars 15 forks source link

Markdown tables are generated without escaping pipe character #11

Open elkoudou opened 3 years ago

elkoudou commented 3 years ago

When a macro (and variables I guess) has a definition or description containing the pipe character "|", it is not escaped and causes missing text in the public description tables.

For instance, let's consider the following code:

/** Test macro
*/
#define MY_MACRO (A | B)
Doxybook will generate: ` Type Name
define MY_MACRO (A B)
Test macro.
`
Which shows: Type Name
define MY_MACRO (A B)
Test macro.

I could fix it locally by adding "|replace()" statements in member_template.py. I could do the same to fix newline being not replaced by <br> by doxybook, causing the rest of the table being displayed in plain text after the table, which may happen when defining global variable.

JakubAndrysek commented 3 years ago

Hi, I am developing a new plugin doxygen-snippets to easy generate documentation with Mkdocs. The plugin is based on this doxybook project. I hope, I have fixed many of the older bugs from this project. So, you could try my project, or fix your problem with add one line of code into doxybook:markdown.py -> ret = ret.replace('|', '\|')

Result:

def escape(s: str) -> str:
    ret = s.replace('*', '\\*')
    ret = ret.replace('_', '\\_')
    ret = ret.replace('<', '&lt;')
    ret = ret.replace('>', '&gt;')
    ret = ret.replace('|', '\|')
    return ret