Hide part of text

  • Some applications
    • Quickly hide in-place some text that should not be deleted.
    • Quickly insert some hidden text in-place, without affecting the structure of the blocks.
  • Preparation
    • Add a macro inside file config.edn , inside macros{} :
    :hidenode "<div class='kit' data-kit='hidenode' data-what='$1' />"
    • The code below requires having kits inside file custom.js .
    • Inside page HideNode in Logseq, put the following code in a javascript code-block:
    const previous = ["pre", "left", "previous"]
    const next = ["next", "post", "right"]
    function getKey(what){
        if (previous.includes(what)) return "previousSibling"
        if (next.includes(what)) return "nextSibling"
    logseq.kits.setStatic(function hidenode(div){
        const divMacro = div.closest(".macro")
        const key = getKey(div.dataset.what)
        if (key) divMacro[key].remove()
  • Usage examples
    • Hide towards the left
      • either:
        • beginning {{hidenode left}}rest of the text
        • beginning {{hidenode pre}}rest of the text
        • beginning {{hidenode previous}}rest of the text
      • it will render like this: rest of the text
    • Hide towards the right
      • either:
        • rest of the text {{hidenode right}}end
        • rest of the text {{hidenode next}}end
        • rest of the text {{hidenode post}}end
      • it will render like this: rest of the text
    • Hide in the middle
      • either:
        • beginning {{hidenode right}}middle text {{hidenode}}end
        • beginning {{hidenode}}middle text {{hidenode left}}end
        • likewise with other keywords
      • it will render like this: beginning end