edoardob90 / jrnl

Collect your thoughts and notes without leaving the command line.
GNU General Public License v3.0
0 stars 0 forks source link

Day One export: multi-line code blocks #4

Open edoardob90 opened 2 days ago

edoardob90 commented 2 days ago

Day One breaks apart a triple-backticks code block and makes a total mess that needs fixing before importing the text correctly.

A simple code block like

import json
from dataclasses import dataclass

def main(a, b, c):
    pass

if __name__ == "__main__":
    print("Nothing happens!")

Gets exported as (where BBB replaces a triple-backticks to avoid messing up with the editor):

# This is a test entry
The purpose is to test a JSON importer.

Here's a multi-line code blocks which Day One probably messes up upon exporting:

BBB  <--- correct
import json
BBB

BBB
from dataclasses import dataclass
BBB

BBB

BBB
BBB
def main(a, b, c):
BBB

    BBB
pass
BBB

BBB

BBB
BBB
if __name__ == "__main__":
BBB

    BBB
print("Nothing happens!")
BBB

Actually, there are two multiline code blocks! What a mess.

BBB <--- correct
# Here's the second code block starts
BBB

BBB

BBB
BBB
import json
BBB

BBB
from dataclasses import dataclass
BBB

BBB

BBB
BBB
def main(a, b, c):
BBB

    BBB
pass
BBB

BBB

BBB
BBB
if __name__ == "__main__":
BBB

    BBB
print("Nothing happens!")
BBB

    BBB
print("For the second time")
BBB <--- correct

Will I be able to extract the text? Only time will tell...

The only correct backticks are those marked with <--- correct; all the others are the result of the bad JSON export.