Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude code blocks from zim2obsidian formatting #21

Closed
laszabine opened this issue Mar 16, 2024 · 7 comments
Closed

Exclude code blocks from zim2obsidian formatting #21

laszabine opened this issue Mar 16, 2024 · 7 comments
Labels
good first issue Good for newcomers

Comments

@laszabine
Copy link

Application/script

Describe the bug
The formatting in zim2obsidian.py should exclude any string that is in a code environment (surrounded by 3 backticks each, perhaps also in-line code environments?).
In my case, I have code environments containing bibtex code which includes the character @ and it got changed to # like a tag.

To Reproduce

  1. Copy my zim repository containing pages with code blocks with bibtex code
  2. Open zim (0.75.2), export to "Markdown (pandoc)", close zim
  3. Create python 3.12.2 venv, launch
  4. Copy zim2obsidian.py to the root location of the copied zim repository
  5. Run python zim2obsidian.py

Expected behavior
Code environments should be excluded from the formatting.

Execution environment:

  • Zim: 0.75.2
  • Python Version: 3.12.2
  • OS: Fedora 39
@peter88213 peter88213 added enhancement New feature or request good first issue Good for newcomers labels Mar 17, 2024
@laszabine
Copy link
Author

laszabine commented Mar 17, 2024 via email

@peter88213 peter88213 added bug Something isn't working and removed enhancement New feature or request labels Mar 17, 2024
@peter88213
Copy link
Owner

Sorry, I deleted my original comment before I saw your reply. I've just looked at it again and I think it can be considered a bug anyway.
I have no experience with pull requests, but you can give it a try.

peter88213 added a commit that referenced this issue Mar 17, 2024
Bugfix: Exclude code blocks from zim2obsidian formatting (#21)

TODO: Update test data.
@peter88213
Copy link
Owner

peter88213 commented Mar 17, 2024

I just committed v0.11.3 that should exclude code blocks.
You find it in this branch.
The changes in the code are not yet tested. You may wish to update the test files and run test_zim2obsidian.py. Then you can contribute the test data and further code changes, if needed.
As soon this is validated, I will publish the release.

Update:
I just did it myself, merged the branch, and closed the issue. Good luck.
If problems occur with your pages and code blocks, just re-open this issue.

peter88213 added a commit that referenced this issue Mar 17, 2024
peter88213 added a commit that referenced this issue Mar 17, 2024
- Fix CODE_BLOCK_MARKER
- Fix a regression where lines that start and end code blocks are
discarded (#21).
- Update test data.
@sojusnik
Copy link

@laszabine

Did you find a solution for the problem where text indentations aren't converted properly, as described here and here?

@peter88213
Copy link
Owner

Please do not use the issue tracker for off-topic conversations, also not in closed issues. Remember that this will send email notifications that are distracting.

Your concern is already clearly visible in the other issues and in the discussions, and I'm sure that anyone who wants to contribute will address it there.

@peter88213 peter88213 removed the bug Something isn't working label Mar 26, 2024
@peter88213
Copy link
Owner

As of version 0.11.6, the zim2obsidian.py script excludes paragraphs that are enclosed with three backticks from conversion, as well as inline text enclosed with a single backtick (see #22).

Actually, enclosing text with backticks is not the way to mark "verbatim" text as specified with Zim:

To render a whole block verbatim, the first and last line of the block should contain 3 quotes and no other characters.

For "Inline code", there is no specification.
However, if you mark verbatim blocks as specified, the Markdown result as exported by Zim is just indented, which is currently not supported by zim2obsidian.py (see #20 ).

For the record: The changes made with version 0.11.6 are actually working, but they are not bug fixes in the true meaning of the word. You can use them, but you should be aware that by using backticks you are deviating from the Zim specification.

peter88213 added a commit that referenced this issue Mar 26, 2024
- Make the "backticks" code conversion an option (#20, #21, #22).
@peter88213
Copy link
Owner

With version 0.13.0 the behavior as requested here is implemented, yet optional.
It can be selected with the --backticks parameter.
See also: #15 (comment)

peter88213 added a commit that referenced this issue Mar 26, 2024
- Make the "backticks" code conversion an option (#9, #20, #21, #22).
peter88213 added a commit that referenced this issue Mar 26, 2024
- Provide an abbreviation for the "backticks" argument
(#9, #20, #21, #22).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants