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 conflicting existing markdown formatting classes, overriding them #9

Open
3 tasks
chuangcaleb opened this issue Oct 5, 2023 · 2 comments
Open
3 tasks
Labels
📋 a/task Type: Task Effort 🤚 b/help-needed Blocker: This ticket is too tough for me! Send help! ✨ o/feature (Feature Requests go to Discussions/Ideas!) Objective: New feature implementation 🪞 s/cm Scope: Codemirror
Milestone

Comments

@chuangcaleb
Copy link
Owner

chuangcaleb commented Oct 5, 2023

The Problem

There are Conflicts between Obsidian-flavored Markdown vs Fountain.

For the > Centred Text < and > Forced Transition Fountain token, Obsidian's standard blockquote token is still detected (since it is a > character that starts a line) and so there are unwanted/conflicting HTML classes being applied (these being cm-formatting-quote cm-formatting-quote-1 cm-quote cm-quote-1 as seen in the screenshot below).

Screenshot 2024-01-29 at 3 28 03 PM

Then Fountain's _Underlined Text_ and /* Boneyard */ tokens conflict with Obsidian's native _Italicised Text_ and * Leading-Asterisk Italicised Text formatting tokens.

The Solution

There are at least two ways to solve this:

Overload(?) Obsidian's native markdown formatting

This is the strategy used for this plugin so far: Obsidian-Fountain-Editor is a superset of Obsidian-flavoured Markdown, so we just add styles on top of existing markdown styles. This is good, because we don't need to reinvent inline boldface, section headings, etc. so it makes sense to continue with this

But when it comes to conflicts where we want Obsidian's regular Markdown to be suppressed (like asterisk italicising), we will have to undo those applied HTML classes.

This may be a lot of funky coding with CodeMirror (which is really complex) and may leave a problematically-HTML-structured CodeMirror document (think weird excessive nested span elements)

Disable Obsidian's native markdown formatting

The other option is to modify the standard markdown processor to prevent triggering certain markdown styles like underscore-italicising, so that our plugin can swoop in and cleanly format underscore-wrapped-text as underlined text.

This is definitely trickier as I don't know of a way to disable core behaviour, much less disable it only for particular documents (remember, other notes should get Obsidian's native markdown formatting as normal). And they probably use some lesser-known efficient low-level parser (like Lezer) (I'm using simple regex!) that may also be locked behind closed-source.

But this definitely is the superior long-term strategy, since (1) it makes for a cleaner HTML DOM, which means cleaner CSS targeting (2) finer-tuned CodeMirror control; especially if there's an API to easily + directly style certain tokens, then that also instantly fixes #11.

Task

  • - blockquote
  • - underline
  • - boneyard
@chuangcaleb chuangcaleb added ✨ o/feature (Feature Requests go to Discussions/Ideas!) Objective: New feature implementation 📋 a/task Type: Task Effort labels Oct 5, 2023
@chuangcaleb chuangcaleb added this to the MVP 2 milestone Oct 5, 2023
@chuangcaleb chuangcaleb added the 🪞 s/cm Scope: Codemirror label Oct 6, 2023
@chuangcaleb chuangcaleb added the 🤚 b/help-needed Blocker: This ticket is too tough for me! Send help! label Oct 16, 2023
@wesleyboar
Copy link
Contributor

wesleyboar commented Jan 27, 2024

I am trying to grok the problem, so I could contribute.

My original understanding, before the update on 2024-01-29…

What I See

  • ✅ Any "> Centered text <"… and "> Forced transition" seem fine…
  • ❌ Any _Underlined text_ is italicized instead of underlined.
  • ❌ Any /* Boneyard */'s:
    • are not styled
    • hide final asterisk
    • italicize final slash
Screenshot 9 maybe a screenshot of the bug
Source Code
---
cssclasses:
  - fountain
---
> Centered text <

> Forced transition

_Underlined text_

/* Boneyard (single line) */

/*
INT. BONEYARD

SOMEONE
Help me.
*/

EXT. BONEYARD

SOMEONE ELSE
You don't look so well.

Questions

  1. What is the "blockquote" problem?
  2. Do I understand the other problems?

@chuangcaleb
Copy link
Owner Author

chuangcaleb commented Jan 29, 2024

Thank you for grokkin with me! — let me update the ticket description. I didn't think I'll be working on this particular one for a while, so I hadn't touched it, please get in touch if you want more explanation! Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📋 a/task Type: Task Effort 🤚 b/help-needed Blocker: This ticket is too tough for me! Send help! ✨ o/feature (Feature Requests go to Discussions/Ideas!) Objective: New feature implementation 🪞 s/cm Scope: Codemirror
Projects
Status: Todo
Development

No branches or pull requests

2 participants