Reading View prototype #33
NickEastNL
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
YO this is NEAT thanks @NickEastNL! And it's cool that you also walked through your thought process. We could modify the Fountain parsing rules to ignore lines starting with Yeah HTML rendering is weird, each line is its own On the note of fonts, yeah we can just change the source CSS to Courier Prime, why not, shall we? Well please feel free to open a PR when you're ready! |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've added rudimentary support for Reading View. It isn't fully functional yet (sections, comments, and the like aren't formatted yet as I don't use them), though it shouldn't be hard to add it (since most of that shouldn't be rendered in a "read view" anyway). I also had to make a compromise to format dialogue with multiple paragraphs. For that reason, I haven't set up a Pull Request.
Due to a limitation in Obsidian's API, a Markdown "Post" Processor can only work with the parsed HTML, rather than the Markdown source. Since whitespace is removed, the double spaces to mark a paragraph break in dialogue cannot be used to format the HTML. A workaround I applied is to put a
\
(backslash) character on the empty line. As this is an escape character, Obsidian will not render it, but the parsed Markdown renders two line breaks (<br>
) instead of one. Since it's also an actual character, Fountain will parse both it and the following line as dialogue. Then as I iterate through each line of dialogue to create paragraphs, I simply include the empty "paragraph" to simulate the paragraph break (as dialogue doesn't have top/bottom margins). In the case of exporting the Fountain content, it shouldn't be too hard to replace\
with two spaces to conform to the spec.Everything else should work fine by simply applying the Fountain rules to the text content of each paragraph. It produces a bit of weird HTML (since each paragraph is nested in a DIV, and since lines starting with
>
produce block quotes), but the rendering should actually be correct. I've added the relevant CSS.Another reason I didn't provide a Pull Request is that I switched to using Courier Prime as the font instead of Courier New, since that's a modern and recommended screenplay font. I didn't have a lot of time to set all this up, since I'm actively using Fountain at the moment and needed to get Reading View to work ASAP, so things might not be very clean and efficient.
I'm providing the diff here to see what I added/changed: master...NickEastNL:obsidian-fountain-editor:read-view
Beta Was this translation helpful? Give feedback.
All reactions