0

M-x replace-regexp RET ^ RET your text RET will add "your text" to the start of every line of an emacs buffer, but how could I do the same to the start of every org-mode paragraph instead, i.e., a text block separated by a hard return?

Yesterday, from this post, I added this

#+HTML_HEAD: <style>p { margin-top: 0px; margin-bottom: 0px; text-indent: 2em; } </style>

to my org-mode buffer for export to html to achieve the "literary style" of paragraphs. However, the text-indent: 2em; part is interfering with something deep in my ox-tufte, so I suppose I need to just add @@html:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp@@ "manually" to the start of every paragraph block as a Plan B ... unless somebody has a better idea...

10
  • 2
    I would not go this way: find out what the incompatibility is and try to fix it instead. What exactly is the problem?
    – NickD
    Commented Oct 16 at 17:16
  • 1
    How about regex with back reference, where the back reference is the whole paragraph?
    – Arktik
    Commented Oct 16 at 17:17
  • @NickD: Because it's aimed at p it is putting that 2em in front of everything -- images, footnotes, etc. That might be uncorrectable. Unless there is a way to specify the containing code, i.e., the actual text p is inside a <div class="outline-text-3" id="text-org7f16d57">, i.e., numbered outline-text-#.
    – 147pm
    Commented Oct 16 at 18:36
  • That should be possible. You can target directives at specific classes or even a specific id, I believe. The syntax is .<class> or #<id>. Google for CSS selectors.So try adding .outline-text-3 { text-indent: 2em; } to your CSS file. Untested and most probably wrong - I'm no expert in these things, but that's what I would try first.
    – NickD
    Commented Oct 16 at 22:57
  • 1
    See my self-answer. It was just guess-and-test until something finally worked. Thanks for your attention to this.
    – 147pm
    Commented Oct 18 at 3:26

1 Answer 1

1

This finally got all the ox-tufte back to normal-looking with the desired literary paragraph style. It was lengthy guess-and-test cycles. I'm sure this is very specific ox-tufte, which is a very deep css rabbit hole. But, yes, if the first line isn't working, (due to p being too inclusive) play around like I did

#+HTML_HEAD: <style> p { margin-top: 0px; margin-bottom: 0px; text-indent: 2em; }  p > .margin-toggle  { text-indent: 0em; }</style>
#+HTML_HEAD: <style> p > .sidenote  { text-indent: -1em; }</style>
#+HTML_HEAD: <style> p > .marginnote { text-indent: 0em; }</style>
1
  • 1
    Here's a little trick to shorten the test cycle: instead of changing the Org file and re-exporting, open the HTML file and edit it, by adding a <style> ... </style> section after the last one in the file and adding your CSS directives; then refresh the page on your browser to see the result. Once you are satisfied, transfer your settings to the Org mode file. Or if you use the CSS file method from your other question, edit it and refresh the page (that's one more reason that I like using a separate CSS file).
    – NickD
    Commented Oct 19 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.