I’ve been having a discussion with several posters, including @Jopp and @CawlinTeffid, about tweaking indents and formatting. Poetry is one area where I’ve seen questions about this in multiple forums, and I thought it would be helpful to the community to start a topic on that.
Here are a few discussion starters:
Do you write poetry?
Do you write other content with particular formatting requirements?
What would you like to be able to accomplish with Obsidian and Markdown formatting?
What problems have you encountered?
What standards or tools have you found that worked? (Fountain, for example)
I am not an expert (I’m an IT professional who writes a lot of prose), but I love making computers sit up and do tricks. I also worked in design studios for a decade and am a bit of a typography geek. This is an invitation for anyone in the community with questions, ideas, experience, tool, or related thoughts to participate.
Yes, I’m writing poetry, and yes (lately) I’m using Obsidian for it. I was using Word before that.
Poetry is not as “template-demanding” as screen play (you mentioned Fountain). So it’s very up to what the poet wants to have.
Currently, I’m using only one approach, and that is something that I want to have. I created a template that automatically applies to the new note in a specific folder. And I get this …
… nothing fancy, but this is all I need. The only important thing is that cssclasses. Then, I wrote a magnificent poem about Lorem ipsum, adding a title, date, and tags. And after hitting this reading mode button, I get this …
If I wanted to apply my poem to a competition, forum, or other event with specific rules, I would translate those rules into CSS. If they accept PDFs, then I would focus on export-to-pdf-css. Most of the time, they have rules about font, spacing, and some styling. It would be a challenge, but not impossible.
(My) Answer to your question: How do I format poetry? - is; with CSS and by my liking
But for initially visualizing spaces and working out appearance and lengths, I gotta do it by hand. I moved on from paper and pencil (wasn’t easy!) and now use a handwriting tablet with amazing text recognition.
When layout will be preserved in publication, I use other tools for submissions anyway, so it doesn’t matter what it looks like in the Obsidian note. I’ll just export an image of it and embed that in the note above the text.
The only finicking I do in Obsidian is cssclasses and callouts for center-align and paragraph-writing (which indents paragraphs except the first paragraph in a section or chapter) along with tags for #indent and #no-indent. The tags override formatting at the line/paragraph level and work in any note, not just poetry compositions.
I follow the recommendations of the HTML spec’s editor to use paragraphs for stanzas and line breaks for lines. (They also suggest using the HTML preformatted text element pre for poems that use creative indentation or spacing; the default rendering for that uses a monospace font, which you may want to change.)
By default Obsidian treats a newline as a line break, but that’s not standard Markdown so may not be treated correctly by other Markdown apps. The official Markdown way to mark a line break, which should work in any Markdown app, is to put 2 or more spaces at the end (Obsidian’s optional “Strict line breaks” setting enforces this). I do this, but it’s obviously a bad syntax because it’s invisible. CommonMark, the standardized Markdown variant that Obsidian’s is ultimately based on, also allows line breaks to be marked with a backslash at the end of the line. That’s less widely compatible but I’d guess still pretty commonly supported.
It may be difficult or impossible to style lines separately (for example to apply a hanging indent when they wrap) when they are only marked by a line break. I think this at least used to be the case but not sure if it’s true now.
Yeah but why and what specific problem resulted you to use CSS or was it just for fun? I think the original question was how Obsidian can be useful when writing poetry.
Some benefits of Obsidian (?) Fast global search accessible using ⌘⇧F High level of portability of your data User automation via community plugins
Some drawbacks of Obsidian (?) Lack of WYSIWYG when exporting to pdf Formatting is achieved using CSS File sharing is complicated (Obsidian Sync/shared vaults or Git)
I think the above replies have hit the common issues:
Line breaks (probably the most basic and common)
Centering
Odd, handmade formatting
I’d forgotten that Obsidian treats a single return as a line break—I generally assume Markdown editors will act like the spec (and HTML) and combine lines by default. That is definitely a weak spot in the Markdown spec and can bit you in the butt when you export to other applications. If I were to use the two-space rule, I’d want to write CSS to display spaces as faint dots or something similar.
I’d already found the cssclasses technique, although I hadn’t thought of applying it to a template or folder. That could be useful in my work, where I write documentation in one of two different formats. Simply switching the CSS class of the note rather than turning on CSS snippets or changing theme would be much simpler to use and only a little more complicated to implement.
Something I’ve seen in a lot of poetry and only referred to here in passing is hanging indents for continued lines. The first issue is how to notate a break which continues a line versus a simple line break—one could manually indent the continued line with two or four spaces, but you’d need to account for what that already means in Markdown (the source of my original question). I’ll have to experiment a bit to see how that works.
Thanks for the tips! I did know about the strict line breaks setting in Obsidian.
Markdown is great because it’s plain text and extremely portable, but there are so many dialects and variations that it gets wonky for more complicated formatting. I try to keep my documents as simple as possible, but there are times when I would like a standard way to do things like merging table cells. Not complaining–it’s still a great tool.
@blue_emperor I tried the plugin, and it works great—thanks for the tip.
Regarding line breaks and indents, I tried formatting my .poetry class with hanging indents—these are the scenarios I’ve tried, all with strict line breaks turned off.
One long paragraph: indents correctly in both live preview and reading mode.
Multiple lines with single carriage returns: formats flush left in live preview and as a single paragraph with line breaks and a hanging indent in reading mode.
Multiple lines with single carriage returns and internal lines indented with tabs: formats flush left with tab indented lines in live preview and as a single paragraph with line breaks and a hanging indent in reading mode (i.e. the same as the previous—tabs are ignored in reading mode).
tl:dr Line breaks format fine. Hanging indents apply to everything but the first line. Tabbed indents are ignored in reading mode. I think that is all expected behavior.
There are ugly ways to force indents, but I can’t think of a clean method that works with the Markdown spec and some clever CSS.
To target an h1 in your class called “poetry”, its .markdown-preview-view.poetry h1 . But that’s just in the Reading view. To also change things in Live Preview:
Thanks—I’d seen some of those but not all. I’ve played with both the classes and Obsidian variables, but documentation is less than complete. Sometimes I can figure out the class using the developer console, but I’m still learning how to read that—just checked out the link, and that’s exactly what I needed. I’m a geek and an IT professional but not a web programmer.
Not specifically into poetry, but I also require center alignment text on some of my notes.
Wanted to share an alternative for those that aren’t that much into CSS / snippets. I, for example, use the following HTML tag: [<]p style=“text-align:center;”>Text</p[>] (just delete the brackets)
Hope this small contribution helps someone out there and thanks for sharing yours too! Comes in really handy
CSS has a way to do hanging indents. Unfortunately it’s not widely supported yet (only in Safari, I think). There’s a hacky way to do it with (if I remember right) a negative first-line indent and a left margin. But as mentioned earlier I’m not sure you can target lines to apply those styles. There’s probably existing discussion online about handling hanging indents in general and in poetry.
Yep—I tried the “hacky” way, which isn’t all that hacky. The problem is applying it where you want it. I’ll have to look at what styles, if any, can be applied to a </br> tag and/or the tab character.
As I’m not writing a lot of poetry, my primary application would be preserving the formatting of quoted passages. Markdown is a writing tool rather than a formatting tool, and some tweaks will have to applied later in the process. Reducing post-processing is still a worthy objective—minimizing tweaking in a tiny embedded knowledge base editor is what got me started on this project.
Yep—that works too. I’m trying to minimize HTML in notes, but I don’t see a way to do all the formatting required by poetry without some custom markup.
Actually, the each-line modifier could be as valuable as the hanging modifier. Used together, they would create a hanging indent for each line of the stanza, so long as you let them wrap automatically. If you wanted to manually place wraps points for long lines, that wouldn’t work.
Oh, yeah, that’s perfect! Thanks for pointing that out! (I haven’t looked at this in a while so not sure if I knew that before and forgot or if it’s just new to me.)