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

Adjust the formatting of code #20

Closed
sojusnik opened this issue Aug 1, 2023 · 4 comments
Closed

Adjust the formatting of code #20

sojusnik opened this issue Aug 1, 2023 · 4 comments
Labels
good first issue Good for newcomers

Comments

@sojusnik
Copy link

sojusnik commented Aug 1, 2023

This script currently converts inline code with two `` and code blocks with tabs, whereas it should do it as mentioned here or according to the following examples:

Zim: An example ''with code'' inside a sentence.
Obsidian: An example `with code` inside a sentence.

A Zim code block:

'''
This is a code block, a code block this is, a code block this is, a code block this is, a code block this is, a code block this is, a code block this is, a code block this is, a code block this is, a code block this is, a code block this is, a code block this is.
'''

The upper and lower ''' from above should be converted to ``` in Obsidian.

While the manual says that a code block can also start with a tab (or 4 spaces), it's rendered weirdly, so therefore the formatting with ``` should be preferred, as shown here:

grafik

While with a tab at the beginning, it looks like
grafik

@peter88213
Copy link
Owner

To be precise, the zim2obsidian script does not change at all the inline code formatting as exported by Zim.
I guess, the problem is that Zim doesn't export "fenced" code blocks, see issue 1718
At the moment, it is marked as an "open issue" in the code.

If you want to do it with zim2obsidian, you have to enhance the code for placing the "fences" around lines beginning with a tab character. This works only, if the tab characters that signify code block lines are not already escaped by subst_indent.py.

I think, this problem is best solved by converting the original Zim notes as discussed in #8.

@peter88213
Copy link
Owner

peter88213 commented Mar 26, 2024

With version 0.11.6, the zim2obsidian.py script supports code blocks that are "fenced" with backticks (see #21). This is not specified with Zim, but it may used as a workaround. Same for "inline code" embraced with single backticks (see #22).

@peter88213
Copy link
Owner

peter88213 commented Mar 26, 2024

Version 0.12.0 converts blocks that are indented with tabs to Obsidian code blocks that are fenced with three backticks.

This is actually the correct method. However, it is in contrast to the behavior required with #11 and #21.
You could consider implementing different operating modes that can be selected via command line parameters.

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

peter88213 commented Mar 26, 2024

Solved with version 0.13.0, see: #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

2 participants