mondeja / mdpo

Markdown files translation using GNU PO files
https://mondeja.github.io/mdpo/
BSD 3-Clause "New" or "Revised" License
25 stars 6 forks source link

Preserve HTML in resulted markdown #240

Closed binotaliu closed 2 years ago

binotaliu commented 2 years ago

I have following markdown file:

# Title

<div id="my-special-div">
content
</div>

- List Item 1
- List Item 2

running po2md mymd.md --pofile mypo.po --quiet --save result.md will result following file:

# Title

- List Item 1
- List Item 2

Is it possible I can reserve the <div> in this file?

I try to read mdpo's source code and was trying to use a enter_block hoot to preserve it. This is my hook file:

import md4c

def skip_entering_html_block(self, block, details):
    if block is md4c.BlockType.HTML:
        return False

After running po2md mymd.md --pofile mypo.po --quiet --save result.md --event enter_block:myhook.py::skip_entering_html_block, the result markdown file is:

# Title

- <div id="my-special-div">
content
</div>
List Item 1

- List Item 2 

The <div> block becomes the content of the first list item.

Is it possible to use hook to archive what I want to do?

mondeja commented 2 years ago

Fixed in v1.0.3