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

Remove markdown from publikator #963

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

annatraussnig
Copy link
Contributor

@annatraussnig annatraussnig commented Nov 20, 2024

Goal

get rid of mdast stringify (mdast->markdown) in publikator.

parsing markdown to mdast is less problematic. We still use markdown strings for templating and parse them to mdast for concision’s sake. this is not a bug-producing process and can be removed ad hoc.

Done

  • code touching article/nl processing doesn’t use markdown anymore, only mdast and slatetree. (no more parse/stringify before commiting)
  • refactor quellcode editor to handle mdast (json)
  • diff in mdast
  • some of the templating is now done directly in mdast

bonus

  • deleted document module: unused and confused, only documentplain is.

Out of Scope

  • tests: many use md and convert it to mdast for concision’s sake. i advise to fix this only if problems arise
  • embed comment: comments are written in markdown and the ui from publikator also allows editing the markdown (easier than mdast for produktion)
  • front: same as tests, templates are laid out in markdown // anyway, the front is not a big problem as far as stability goes for now

TODO:

  • test
  • check that backend doesn't do any stringify-parsing

@annatraussnig annatraussnig requested a review from jstcki November 20, 2024 15:57
Copy link
Contributor

@jstcki jstcki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might not have fully understood everything, feel free to ignore my comments if they don't make sense :)

),
),
content: JSON.parse(
JSON.stringify(this.editor.serializer.serialize(editorState)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why are we still stringify-parsing here? Doesn't serialize give us an mdast already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just to make a deep copy. we are stringify-parsing to JSON, not markdown. but i understand that it offends you and we should find a more transparent solution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But do we even need to make a copy here? It's just used as an argument for the mutation …

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason that I can think of why this could be necessary is if serialize() doesn't return a plain JSON object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is dangerous to ask oneself this kind of questions, Jeremy. (Aka: not sure why it's here, perhaps it's just a remnant from the markdown stringify-parsing – I'll investigate.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it was because stringifying to markdown was not playing nice with slate, so we needed to execute that operation on a copy of the editor state... so you are probably right, we don't need it. Will try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants