[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr e45b0e43e8 1/3: fix: Don't allow multi-line stri
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr e45b0e43e8 1/3: fix: Don't allow multi-line strings to indent by more than 2 spaces |
Date: |
Thu, 12 May 2022 01:57:54 -0400 (EDT) |
branch: externals/tomelr
commit e45b0e43e80cc9df796027674a412708050ec8d6
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
fix: Don't allow multi-line strings to indent by more than 2 spaces
The `tomelr-indent-multi-line-strings` variable is set to `t' mainly
by ox-hugo. So these multi-line strings will most likely be parsed by
Hugo as Markdown. If the indentation of lines in these strings is 4
spaces or more, they get parsed as code blocks! So limit the
indentation of these strings to just 2 spaces.
---
test/tstring.el | 34 +++++++++++++++++-----------------
tomelr.el | 9 +++++----
2 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/test/tstring.el b/test/tstring.el
index 002b5ed0df..f8c8087e9c 100644
--- a/test/tstring.el
+++ b/test/tstring.el
@@ -75,35 +75,35 @@ xyz\"\"\""
\"\"\""
"[table]
key = \"\"\"
- abc
- def
- \"\"\""
+ abc
+ def
+ \"\"\""
"[[table_array]]
key = \"\"\"
- abc
- def
- \"\"\"
+ abc
+ def
+ \"\"\"
[[table_array]]
key = \"\"\"
- klm
- xyz
- \"\"\""
+ klm
+ xyz
+ \"\"\""
"[[table_array]]
key = \"\"\"
- abc
+ abc
- def
- \"\"\""
+ def
+ \"\"\""
"[[table_array]]
key = \"\"\"
- abc
+ abc
- def
+ def
- foo
- bar
- \"\"\""
+ foo
+ bar
+ \"\"\""
))
out)
(dolist (el inp)
diff --git a/tomelr.el b/tomelr.el
index 916191aa33..0d9ac8435b 100644
--- a/tomelr.el
+++ b/tomelr.el
@@ -209,10 +209,11 @@ Return the same STRING passed as input."
(setq begin-q "\"\"\"\n")
(setq end-q "\"\"\"")
(when tomelr-indent-multi-line-strings
- (let ((indentation (let ((tmp ""))
- (dotimes (_ (1+ tomelr--print-indentation-depth))
- (setq tmp (concat tmp
tomelr-encoding-default-indentation)))
- tmp)))
+ (let (;; Fix the indentation of multi-line strings to 2
+ ;; spaces. If the indentation is increased to 4 or more
+ ;; spaces, those strings will get parsed as code blocks
+ ;; by Markdown parsers.
+ (indentation " "))
(setq string
(concat
indentation ;Indent the first line in the multi-line string