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

FIX: (adoc-promote): headings get wrongfully turned into sub-type 2 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions adoc-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,14 @@ removed before TRANSFORM is evaluated.

(ert-deftest adoctest-test-promote-title ()
(adoctest-trans "= foo" "== foo" '(adoc-promote-title 1))
(adoctest-trans "= <foo>

bar"
"== foo

bar"
'(adoc-promote-title 1))
(adoctest-trans "= foo " "== foo" '(adoc-promote-title 1))
(adoctest-trans "===== foo" "= foo" '(adoc-promote-title 1))
(adoctest-trans "== foo" "==== foo" '(adoc-promote-title 2))

Expand Down
3 changes: 2 additions & 1 deletion adoc-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@

(require 'markup-faces) ; https://github.com/sensorflo/markup-faces
(require 'cl-lib)
(eval-when-compile (require 'subr-x))
(require 'tempo)

(defconst adoc-mode-version "0.6.6"
Expand Down Expand Up @@ -2699,7 +2700,7 @@ trailing delimiter ('== my title ==').
((looking-at (adoc-re-one-line-title level))
(setq type 1)
(setq text (match-string 2))
(setq sub-type (if (< 0 (length (match-string 3))) 2 1))
(setq sub-type (if (< 0 (length (string-trim-right (match-string 3)))) 2 1))
(setq found t))
;; WARNING: if you decide to replace adoc-re-two-line-title with a
;; method ensuring the correct length of the underline, be aware that
Expand Down