1

my package mastodon.el uses shr-render-region to render posts, which fills text at shr-width.

if the post contains inline latex, shr's filling will split up the latex so that it will not be possible to render it in emacs subsequently.

is it possible to prevent shr from splitting inside a latex block?

inline latex blocks are surrounded by \(...\) or \[...\] characters in the html.

i tried adding a custom predicate function to fill-nobreak-predicate, with regexes checking if point is in-between \ and [ or ( characters, or inside a \(...\) or \[...\] block, as i understood shr to defer to fill.el's checks, but this doesn't seem to work. is that the correct way to go about this?

it looks like the most common or perhaps even only case where the latex breaks is when filling breaks a line between a \ and ( or [.

EDIT:

from further debugging, it appears that in shr-find-fill-point, the line (shr-char-kinsoku-eol-p (following-char)), returns t when called when point is between the \ and [ or ( of a latex block, allowing the linebreak to occur at that point. it ought to return nil, like all the other tests in that function, so that point is moved backwards by one character, and then split should be permitted, with point after a space and before a \( or \[.

so it looks like my fil-nobreak regex is being ignored.

can the kinsoku rules be avoided or ignored somehow?

0

Your Answer

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

Browse other questions tagged or ask your own question.