Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backslash in search-replace and search-replace output dependent #3

Closed
dropsplash opened this issue Mar 15, 2024 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@dropsplash
Copy link

Hello,

Thanks for yout code; very useful.
Would it be possible to have in

search-replace:
\quarto : "Quarto something"
"\quarto": "Quarto something"
"\quarto": "Quarto"

It seems that the backslash in any form of the previous yaml header can not be used to trigger a search-replace; maybe I missed something

Also, it would be nice to have the possibility of having a search replacement that is format output-dependent. The same keyword with different output depending on the format is pdf, HTML, Latex, or Word. Do you have any idea how to do that?

Many thanks
Regards

@ute
Copy link
Owner

ute commented Mar 16, 2024

Backslash is an escape character and gets processed or rather throws errors before the filter can do its work. You would need to use double backslash: "\quarto" is working. It then also needs to be doubled in the text.
It seems you are trying to replace LaTeX macros (I was hoping to be able to do that, too). One way to go is using pandoc to translate LaTeX into markdown.

Your other suggestion, with format dependent replacements, sounds interesting. I think it could be done, but it will require a big rewrite, including defining some sensible yaml syntax, or making the filter read translation lists from files. I wish I had time for coding - it is not going to happen in the next six months or so. If you (or someone else) wants to tackle this enhancement, a pull request would be very welcome :-)

@ute ute added the enhancement New feature or request label Mar 16, 2024
@dropsplash
Copy link
Author

Hello,

I can't make it work \quarto either with one or two backslash

Your other suggestion, with format dependent replacements, sounds interesting. I think it could be done, but it will require a big rewrite, including defining some sensible yaml syntax, or making the filter read translation lists from files. I wish I had time for coding - it is not going to happen in the next six months or so. If you (or someone else) wants to tackle this enhancement, a pull request would be very welcome :-)

For my other suggestion, I found in the doc here a way to have a format-dependent option. I did not try but it seems that it is already directly implemented in quarto.

contributes:
format:
common:
filters:
- filter.lua
shortcodes:
- quarto-ext/fancy-text
html:
# html-specifc
pdf:
# pdf-specifc

@ute
Copy link
Owner

ute commented Mar 21, 2024

Hmmm... It worked with double backslash for me. You need to put apostrophes around, and use double backslash also in the text.

As to your suggestion using the extension yaml: I thought you wanted the end user to decide which replacements are used under html or under pdf format? The quarto feature lets you decide which filter is in action. You could actually use it for a quick-and-dirty solution making copies of the actual filter and changing the yaml keyword inside, to e.g. 'search-replace-html'

@ute
Copy link
Owner

ute commented Apr 1, 2024

@dropsplash , thank you for your feature suggestion! Ive put this into a separate issue, #4.

Are you still having trouble with backslashes? If yes, which quarto version are you using?

@ute
Copy link
Owner

ute commented May 9, 2024

Format specific search replace is coming soon and is followed in #4

@ute ute closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants