diff --git a/modele-article.org b/modele-article.org index 587b682..a38de14 100644 --- a/modele-article.org +++ b/modele-article.org @@ -61,16 +61,18 @@ ci-dessus. Essayez de commenter votre code et vos commandes shell de manière à ne pas avoir d'immenses blocs de code ou de sorties shell qui rendent l'article illisible. -#+ATTR_LINUXMAG-FR: :note PAO +#+begin_note_pao Le texte ici est destiné à indiquer des informations supplémentaires à la rédaction. Il n'apparaîtra pas dans l'article final. +#+end_note_pao Pour une note apparaissant dans l'article final il faut seulement supprimer le terme PAO : -#+ATTR_LINUXMAG-FR: :note t +#+begin_note Le texte présent ici, rédigé en style « Normal », apparaîtra dans l'article final dans une boîte spéciale « note ». +#+end_note Les indications en style « pragma », comme ci-dessus, doivent toujours être encadrées de 3 slashs ​/​/​/​…/​/​/. @@ -78,13 +80,15 @@ Les indications en style « pragma », comme ci-dessus, doivent toujours Si vous souhaitez une note ayant pour titre : Avertissement ou Attention (avec la petite icône associée), il faut utiliser : -#+ATTR_LINUXMAG-FR: :note attention +#+begin_note_attention Le texte présent ici, rédigé en style « Normal », apparaîtra dans l'article final dans une boîte spéciale « Attention ». +#+end_note_attention -#+ATTR_LINUXMAG-FR: :note avertissement +#+begin_note_avertissement Le texte présent ici, rédigé en style « Normal », apparaîtra dans l'article final dans une boîte spéciale « Avertissement ». +#+end_note_avertissement Les sessions de commandes interactives sont à utiliser avec le style de paragraphe « console ». On peut également mettre en évidence diff --git a/ox-linuxmag-fr.el b/ox-linuxmag-fr.el index babe355..b8f1ca0 100644 --- a/ox-linuxmag-fr.el +++ b/ox-linuxmag-fr.el @@ -331,40 +331,43 @@ INFO is a plist holding contextual information." "Transcode a PARAGRAPH element from Org to ODT. CONTENTS is the contents of the paragraph, as a string. INFO is the plist used as a communication channel." - (let ((note-type (org-export-read-attribute :attr_linuxmag-fr paragraph :note))) - (cond - (note-type - (ox-linuxmag-fr--format-note contents note-type)) - ((ox-linuxmag-fr--is-paragraph-a-figure-p paragraph info) - (ox-linuxmag-fr--format-figure paragraph contents info)) - (t - (let* ((parent (org-export-get-parent paragraph)) - (parent-type (org-element-type parent)) - (prefix (when (eq parent-type 'item) "- "))) - (org-odt--format-paragraph - paragraph - (concat prefix contents) - info - "Normal" "" "")))))) + (cond + ((ox-linuxmag-fr--is-paragraph-a-figure-p paragraph info) + (ox-linuxmag-fr--format-figure paragraph contents info)) + (t + (let* ((parent (org-export-get-parent paragraph)) + (parent-type (org-element-type parent)) + (prefix (when (eq parent-type 'item) "- ")) + (style (if (and + (eq parent-type 'special-block) + (equal (org-element-property :type parent) "note_pao")) + "pragma" + "Normal"))) + (org-odt--format-paragraph + paragraph + (concat prefix contents) + info + style + "" ""))))) (defun ox-linuxmag-fr--format-note (contents note-type) "Return a string containing CONTENTS with a box markup. -NOTE-TYPE is a string representing the kind of box." - (cl-case (intern note-type) +NOTE-TYPE is a symbol representing the kind of box." + (cl-case note-type (PAO (concat (ox-linuxmag-fr--format-pragma "Début note PAO") - (ox-linuxmag-fr--format-textp contents "pragma") + contents (ox-linuxmag-fr--format-pragma "Fin note PAO"))) ((attention avertissement) (concat - (ox-linuxmag-fr--format-pragma (format "Début note : %s" (capitalize note-type))) - (ox-linuxmag-fr--format-textp contents) + (ox-linuxmag-fr--format-pragma (format "Début note : %s" (capitalize (symbol-name note-type)))) + contents (ox-linuxmag-fr--format-pragma "Fin note"))) (t (concat (ox-linuxmag-fr--format-pragma (format "Début note")) - (ox-linuxmag-fr--format-textp contents) + contents (ox-linuxmag-fr--format-pragma "Fin note"))))) (defun ox-linuxmag-fr--format-figure (paragraph _contents info) @@ -397,6 +400,10 @@ contextual information." (let ((type (intern (org-element-property :type special-block)))) (cl-case type (encadre (ox-linuxmag-fr--format-encadre special-block contents)) + (note (ox-linuxmag-fr--format-note contents 'default)) + (note_pao (ox-linuxmag-fr--format-note contents 'PAO)) + (note_avertissement (ox-linuxmag-fr--format-note contents 'avertissement)) + (note_attention (ox-linuxmag-fr--format-note contents 'attention)) (t contents)))) (defun ox-linuxmag-fr--format-encadre (special-block contents) diff --git a/test/ox-linuxmag-fr-tests.el b/test/ox-linuxmag-fr-tests.el index 9ff1741..eab4883 100644 --- a/test/ox-linuxmag-fr-tests.el +++ b/test/ox-linuxmag-fr-tests.el @@ -170,27 +170,51 @@ See figure [[mypicture2]].") (should (ox-linuxmag-fr-tests-contain "Foo https://damien.cassou.me"))) (ert-deftest ox-linuxmag-fr-tests-paragraph-note-PAO () - (ox-linuxmag-fr-tests-export "#+ATTR_LINUXMAG-FR: :note PAO\nLe texte") + (ox-linuxmag-fr-tests-export " +#+begin_note_pao +Le texte +#+end_note_pao") (should (ox-linuxmag-fr-tests-contain "/// Début note PAO ///")) - (should (ox-linuxmag-fr-tests-contain "Le texte")) + (should (ox-linuxmag-fr-tests-contain "Le texte\n")) (should (ox-linuxmag-fr-tests-contain "/// Fin note PAO ///"))) (ert-deftest ox-linuxmag-fr-tests-paragraph-note-attention () - (ox-linuxmag-fr-tests-export "#+ATTR_LINUXMAG-FR: :note attention\nLe texte") + (ox-linuxmag-fr-tests-export " +#+begin_note_attention +Le texte +#+end_note_attention") (should (ox-linuxmag-fr-tests-contain "/// Début note : Attention ///")) - (should (ox-linuxmag-fr-tests-contain "Le texte")) + (should (ox-linuxmag-fr-tests-contain "Le texte\n")) (should (ox-linuxmag-fr-tests-contain "/// Fin note ///"))) (ert-deftest ox-linuxmag-fr-tests-paragraph-note-avertissement () - (ox-linuxmag-fr-tests-export "#+ATTR_LINUXMAG-FR: :note avertissement\nLe texte") + (ox-linuxmag-fr-tests-export " +#+begin_note_avertissement +Le texte +#+end_note_avertissement") (should (ox-linuxmag-fr-tests-contain "/// Début note : Avertissement ///")) - (should (ox-linuxmag-fr-tests-contain "Le texte")) + (should (ox-linuxmag-fr-tests-contain "Le texte\n")) (should (ox-linuxmag-fr-tests-contain "/// Fin note ///"))) (ert-deftest ox-linuxmag-fr-tests-paragraph-note-default () - (ox-linuxmag-fr-tests-export "#+ATTR_LINUXMAG-FR: :note t\nLe texte") + (ox-linuxmag-fr-tests-export " +#+begin_note +Le texte +#+end_note") + (should (ox-linuxmag-fr-tests-contain "/// Début note ///")) + (should (ox-linuxmag-fr-tests-contain "Le texte\n")) + (should (ox-linuxmag-fr-tests-contain "/// Fin note ///"))) + +(ert-deftest ox-linuxmag-fr-tests-paragraph-note-default-several-paragraphs () + (ox-linuxmag-fr-tests-export " +#+begin_note +Le texte + +Autre texte +#+end_note") (should (ox-linuxmag-fr-tests-contain "/// Début note ///")) - (should (ox-linuxmag-fr-tests-contain "Le texte")) + (should (ox-linuxmag-fr-tests-contain "Le texte\n")) + (should (ox-linuxmag-fr-tests-contain "Autre texte\n")) (should (ox-linuxmag-fr-tests-contain "/// Fin note ///"))) (ert-deftest ox-linuxmag-fr-tests-paragraph-picture ()