问题是,从源块引用带有特殊字符(例如
|
)的表。在这种情况下,它被解释为列分隔符。建议使用 LaTeX 符号,但这会在 LaTeX 以外的语言的源代码块级别上引入复杂性。对于 sh
,解决方案 1 有效,但显然不能概括。解决方案 2 可以概括,因为代码位于标头中,但我无法让它工作。我想知道
如果可能无法利用 ox-latex
的代码或其他方法来解决此问题。或者,我是否应该完全放弃表并考虑使用 YAML 源代码块等替代方案?
分享:
#+name: tbl-debug-1
| class | regex |
|-------+----------------|
| foo | html\vert{}tex |
解决方案1:
#+header: :var var=tbl-debug-1
#+header: :results raw verbatim
#+begin_src sh
echo "${var}" | sed 's/\\vert{}/|/'
#+end_src
#+RESULTS:
foo html|tex
解决方案2:
#+begin_src emacs-lisp
(defun erw/unlatex (table)
"Replace \\vert{} with | withn Org table."
(mapcar (lambda (row)
(if (listp row)
(mapcar (lambda (cell)
(if (stringp cell)
(replace-regexp-in-string "\\\\vert{}" "|" cell)
cell))
row)
row))
table))
#+end_src
#+RESULTS:
: erw/unlatex
#+header: :var input=(erw/unlatex (org-babel-ref-resolve "tbl-debug-1"))
#+header: :results raw verbatim
#+begin_src sh
declare -A my_assoc
while read key value
do
my_assoc[$key]=${value}
done <<< "${input}"
declare -p my_assoc
#+end_src
#+RESULTS:
declare -A my_assoc=([foo]=$'html\ttex' )
先例:
“很棒的文章!我很欣赏你如何解释[博客中的特定主题]。我特别发现你关于[特定细节]的观点很有洞察力,因为它与我在经验中看到的有效策略相一致。对于那些对此主题感兴趣的人,我还在我的博客上写了相关主题,在其中分享了有关您的内容的简短价值主张的提示,感谢您分享如此宝贵的见解!” https://ifda.in/mern-stack-development-course.php