Macros in CJK text

Macros only render if a space precedes them.
Languages such as Chinese or Japanese do not use spaces, thus making it impossible to use macros.

foo {{macro}}bar ← renders
foo{{macro}}bar ← does not render
青い{{macro}}です。 ← does not render

Consider passing the surrounding text as parameter, either:

  • only before
    • definition: :macro "$1何か"
    • usage: {{macro 青い}}です。
  • both before and after
    • definition: :macro "$1何か$2"
    • usage: {{macro 青い, です。}}

Thanks for the reply.
Unfortunately, that approach does not really solve the problem.

For example if I have:

:macros {
           "ruby" "<ruby>$1<rt>$2</rt></ruby>"

Then, if I write “これは{{ruby 青, あお}}い何かです。” the macro does not get parsed by Logseq and will simply render as it is, i.e. “これは{{ruby 青, あお}}い何かです。”.

But if I write “これは {{ruby 青, あお}}い何かです。” (note the space before the opening curly bracket) then it will render as “これは あおい何かです。”.

Similarly, in English, if I have

:macros {
           "cite" "<cite class='$1'>$2</cite>"

And have a block like ‘For details see “{{cite paper, Article Title}}” in Awesome Journal.’ It will not render unless I insert a space character between the opening quote and opening curly bracket.

Thanks in advance

The problem is real.

  • My suggestion was merely a possible workaround.
  • Currently you may remove the undesired space only through scripting.

Hopefully, the Logseq team will eventually solve the problem at its core.

For the time being, here is the workaround I came up with:

  1. Add an extra space before every macro.
  2. Shift every macro to the left by the width of a space (5em/18) using CSS.
.macro {
    margin-left: calc(-5em / 18);

I just noticed that block references run into the exact same problem, i.e. the opening double bracket requires a space.