mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Support for extracting raw text, and replacing raw text. #205
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pauldotknopf on GitHub (May 3, 2018).
I have a requirement to support generating translated markdown documents from POT/PO files.
I need to parse a document for all raw string values. I will use this to generate a POT document that translators will use to create new languages.
I also need to support replacing raw text during rendering to enable replacing text with the translated value.
Any guidance would be greatly appreciated!
@pauldotknopf commented on GitHub (May 4, 2018):
Ok, so I figured it out. Let me know if I am heading down a wrong/stupid track?
Here are is my test case which illustrates my requirements.
Here is what my internal implementation looks like.
The key part in the above code is my custom
TextReplacementRenderer.The main thing I'm worried about is that the start/end/position properties used all over the place would be invalid. Should I be? Is this approach ok?
@pauldotknopf commented on GitHub (May 6, 2018):
Ok, so I've done some more research, and here are my thoughts. Forgive me for thinking out-loud on a public forum. Any input would be appreciated!
I've implemented a custom renderer that just outputs the the syntax in an easy-to-read structure.
Markdown:
Syntax:
I think i've identified the type that will have it's raw contents translated, which is a
ContainerInline. I will have a custom renderer that will simple pass the raw markdown through to the new content, but forContainerInline, the content will be translated.@pauldotknopf commented on GitHub (May 6, 2018):
@xoofx, can
ContainerInlinebe nested? I'm wondering if I need to support translations withThis is {0} a translationwhere{0}is replaced with the innerContainerInline.@pauldotknopf commented on GitHub (May 6, 2018):
I created a custom
ContainerInlineRendererthat simply passes through the raw inner markdown. My translation engine will eventually be translating this value, as is.My new markdown syntax:
@pauldotknopf commented on GitHub (May 7, 2018):
I finished the library for translating markdown files here. Looking at the tests can give you a good idea of what it does.
With that said, I have effectively answered the original question.
Thanks for listening to me :)