[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [FR] :noweb-wrap header arg
From: |
Ihor Radchenko |
Subject: |
Re: [FR] :noweb-wrap header arg |
Date: |
Thu, 23 May 2024 11:27:58 +0000 |
Amy Grinn <grinn.amy@gmail.com> writes:
>> I recommend the following:
>>
>> If the value starts from ", use Elisp's `read':
>> |"# <<" ">>"
>> (read (current-buffer)) ; => "# <<"
>> otherwise, consider read until the first whitespace.
>> |#<<; >>;
>> (re-search-forward (rx (1+ (not whitespace))))
>> #<<;|
>>
>> However, there may be edge cases like
>>
>> "<< >>"
>> "<< >>
>> << << >>
>> << "asd" >>
>
> I didn't implement this recommendation yet; I still think the regex is a
> more clear way of putting it, even without using a temporary buffer:
>
> ;; If a pair of " is found separated by one or more
> ;; characters, capture those characters as a group
> (unless (eq i (string-match (rx (* space) ?\"
> (group (+ (not ?\")))
> ?\" (* space))
> raw i))
> ;; Otherwise, capture the next non-whitespace group of
> ;; characters
> (string-match (rx (* space) (group (* (not space))) (* space))
> raw i))
>
> Let me know what you think!
Consider cases like
"< \"" "\" >"
or
"< >"
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>