diff --git a/plantuml-mode.el b/plantuml-mode.el index c411308..94d1644 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -586,7 +586,7 @@ or it is followed by line end.") (defvar plantuml-indent-regexp-footer-start "^\s*\\(?:\\(?:center\\|left\\|right\\)\s+footer\\|footer\\)\s*\\('.*\\)?$") (defvar plantuml-indent-regexp-legend-start "^\s*\\(?:legend\\|legend\s+\\(?:bottom\\|top\\)\\|legend\s+\\(?:center\\|left\\|right\\)\\|legend\s+\\(?:bottom\\|top\\)\s+\\(?:center\\|left\\|right\\)\\)\s*\\('.*\\)?$") (defvar plantuml-indent-regexp-oldif-start "^.*if\s+\".*\"\s+then\s*\\('.*\\)?$" "used in current activity diagram, sometimes already mentioned as deprecated") - (defvar plantuml-indent-regexp-newif-start "^\s*if\s+(.*)\s+then\s*.*$") + (defvar plantuml-indent-regexp-newif-start "^\s*\\(?:else\\)?if\s+(.*)\s+then\s*.*$") (defvar plantuml-indent-regexp-macro-start "^\s*!definelong.*$") (defvar plantuml-indent-regexp-user-control-start "^.*'.*\s*PLANTUML_MODE_INDENT_INCREASE\s*.*$") (defvar plantuml-indent-regexp-start (list plantuml-indent-regexp-block-start @@ -614,7 +614,7 @@ or it is followed by line end.") (defvar plantuml-indent-regexp-footer-end "^\s*endfooter\s*\\('.*\\)?$") (defvar plantuml-indent-regexp-legend-end "^\s*endlegend\s*\\('.*\\)?$") (defvar plantuml-indent-regexp-oldif-end "^\s*\\(endif\\|else\\)\s*\\('.*\\)?$") - (defvar plantuml-indent-regexp-newif-end "^\s*\\(endif\\|else\\)\s*.*$") + (defvar plantuml-indent-regexp-newif-end "^\s*\\(endif\\|elseif\\|else\\)\s*.*$") (defvar plantuml-indent-regexp-macro-end "^\s*!enddefinelong\s*\\('.*\\)?$") (defvar plantuml-indent-regexp-user-control-end "^.*'.*\s*PLANTUML_MODE_INDENT_DECREASE\s*.*$") (defvar plantuml-indent-regexp-end (list plantuml-indent-regexp-block-end diff --git a/test/plantuml-indentation-activity-new-test.el b/test/plantuml-indentation-activity-new-test.el new file mode 100644 index 0000000..b097df5 --- /dev/null +++ b/test/plantuml-indentation-activity-new-test.el @@ -0,0 +1,75 @@ +;;; plantuml-indentation-activity-old-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*- + +;; Author: René Schmelzer +;; Maintainer: Carlo Sciolla (skuro) +;; URL: https://github.com/skuro/plantuml-mode + +;;; Commentary: + +;; Test indentation for activity (old version) diagrams. + +;;; Code: + + +(ert-deftest plantuml-test-indentation/activity-new/start-stop () + "Test correct indentation of plantuml activity-new diagram elements: start-stop. +These code examples are taken from www.plantuml.com" + (plantuml-test-indent-block +"@startuml +start +:Hello world; +:This is defined on +several **lines**; +end +@enduml" + +"@startuml +start +:Hello world; +:This is defined on +several **lines**; +end +@enduml")) + +(ert-deftest plantuml-test-indentation/activity-new/conditional () + "Test correct indentation of plantuml activity-new diagram conditionals. +These code examples are taken from www.plantuml.com" + (plantuml-test-indent-block +"@startuml +start +if (condition A) then (yes) +:Text 1; +elseif (condition B) then (yes) +:Text 2; +stop +elseif (condition C) then (yes) +:Text 3; +elseif (condition D) then (yes) +:Text 4; +else (nothing) +:Text else; +endif +stop +@enduml" + +"@startuml +start +if (condition A) then (yes) + :Text 1; +elseif (condition B) then (yes) + :Text 2; + stop +elseif (condition C) then (yes) + :Text 3; +elseif (condition D) then (yes) + :Text 4; +else (nothing) + :Text else; +endif +stop +@enduml")) + + +(provide 'plantuml-indentation-activity-new-test) + +;;; plantuml-indentation-activity-old-test.el ends here