emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix regex for determining image width from attribute


From: Max Nikulin
Subject: Re: [PATCH] Fix regex for determining image width from attribute
Date: Thu, 25 Nov 2021 23:43:29 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

On 25/11/2021 00:00, Max Nikulin wrote:
On 24/11/2021 22:59, Matt Huszagh wrote:

I am sorry that I confused you by my note concerning space before :width. I am afraid, current variant means repeated ":"

+                      (concat "^[ \t]*#\\+attr_"
+                              backend
+                              ":+.*? :width +\\(\\S-+\\)")))
                                  ^
----------------------------------'

Is space after "#+attr_XXX:" is required at all? Is something besides spaces allowed here?

Of course, another attributes may be there.

Untested:
":\\s-*:width\\s-+\\(\\S-+\\)"
I am unsure concerning newlines as space characters, so the following, perhaps, is more correct:
":[^\n\\S-]*:width[^\n\\S-]+\\(\\S-+\\)"

Actually value is everything till line end besides trailing spaces, so precise regexp should be a bit longer.

I am confused. I can not figure out how to create the following as HTML export result:

<img src="img.png" alt="An image without :width 600 attribute">

Attempt to add quotes leads to &quot; and does not prevent ":width" to become another attribute.

  #+attr_html: :alt An image without :width 600 attribute
  [[file:img.png]]

  <p><img src="img.png" alt="An image without" width="600 attribute" />
</p>

My current variant:

":\\(?:[^\n]*?[[:blank:]]\\)?:width[[:blank:]]+\\(\\S-+\\)"

The regexp should not match e.g.

#+attr_html: :alt something
:width 600

P.S. I would prefer to use the same parser as ox does.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]