Code Monkey home page Code Monkey logo

org-extra-emphasis's Introduction

Table of Contents

org-extra-emphasis: Extra Emphasis markers for Emacs Org mode

This library provides two additional markers !! and !@ over and above those in org-emphasis-alist.

  • Text enclosed in !! is highlighted in yellow, and exported likewise
  • Text enclosed in !@ is displayed in red, and exported likewise

Following backends are supported: HTML and enhanced ODT

Setup

Add the following to your user-init-file and resetart Emacs.

(require 'org-extra-emphasis)

Test Run

  1. Create an org file, say org-export-emphasis.org and fill it with following content.
	  #+TITLE: Test file for ==org-extra-emphasis== library

	  * Demo of extra emphasis markers ==!!== and ==!@==

	  !!Ea consectetur laboris adipiscing et ipsum labore esse qui minim
	  pariatur et sunt sunt nostrud anim laborum culpa.!!

	  !@Minim reprehenderit excepteur elit, dolore elit, veniam, eu.
	  Ullamco dolore elit, cupidatat sed labore ea aute.!@

	  Pariatur !!et lorem cupidatat !@minim irure!@ proident, ad.!!  Eiusmod
	  sunt et lorem labore ex aliqua aute esse.

	  Ut mollit !@duis velit est est magna in quis ipsum.  !!Aliqua aliqua
	  non laboris exercitation cupidatat aliqua incididunt.!!  Qui voluptate
	  irure aute occaecat laborum cillum est.!@  Quis magna dolor ullamco
	  magna do consectetur est laborum enim ut.

	  * !!Demo of extra emphasis markers in a styled paragraph!!

	  #+ATTR_ODT: :target "extra_styles"
	  #+begin_src nxml
	  <style:style style:name="Warn"
		       style:parent-style-name="Text_20_body"
		       style:family="paragraph">
	    <style:paragraph-properties>
	      <style:tab-stops />
	    </style:paragraph-properties>
	    <style:text-properties fo:background-color="#ff0000"
				 fo:color="#ffffff"
				 fo:font-size="20pt"
				 fo:font-style="italic"
				 fo:font-weight="bold" />
	  </style:style>
	  #+end_src

	  #+ATTR_ODT: :style "Warn"
	  Proident, duis dolore consectetur sed nisi ea pariatur.  Esse
	  proident, cillum duis qui ullamco sint cillum magna.  !!Eiusmod
	  veniam, !@sint officia!@ non consectetur laboris cillum.!!  Cillum
	  mollit consequat eu dolore ullamco qui reprehenderit anim cillum
	  in consectetur consequat sunt dolore aliquip voluptate
	  consectetur anim ea.  Voluptate nisi est incididunt aliquip
	  excepteur aliqua id do enim ut non consequat.
	  
  1. When in org-extra-emphasis.org buffer, note that portions of text marked with !! and !@ are fontified as described above.

  2. Export the file to HTML with C-c C-e h O.

    Note that the text enclosed in the above emphasis markers are colorized in HTML file.

  3. Export the file to ODT with C-c C-e o O.

    Note that the text enclosed in the above emphasis markers are colorized in ODT file.

Screenshots

org-extra-emphasis.org as viewed in Emacs

org-extra-emphasis.org as viewed in Emacs

org-extra-emphasis.html as viewed in Firefox

org-extra-emphasis.org as viewed in Firefox

org-extra-emphasis.odt as viewed in LibreOffice

org-extra-emphasis.org as viewed in LibreOffice

org-extra-emphasis.pdf as exported by LibreOffice

org-extra-emphasis.org as viewed in LibreOffice

Customization

Customize org-extra-emphasis-alist to set the emphasis markers and their associated faces. When choosing your own marker, ensure that you exercise some care. For example, if you choose # as a marker you are likely to get malformed html and odt files.

This library defines two faces org-extra-emphasis-1and org-extra-emphasis-2.

You can use M-x org-extra-emphasis-mode to toggle this feature.

To add additional backends, modify org-extra-emphasis-formatter and org-extra-emphasis-build-backend-regexp.

org-extra-emphasis's People

Contributors

kjambunathan avatar

Stargazers

patrik avatar Roman avatar Vlad λ avatar Matthew J. Delhey avatar Mr Unhappy avatar Grant Rettke avatar Kristoffer Balintona avatar Merghadi Abdelaziz avatar VitalyR avatar 肥肥 avatar  avatar Théo Tyburn avatar Nathan Sharp avatar tomoyukim avatar swint avatar Lucius avatar  avatar StrawberryTea avatar yibie avatar Akira Komamura avatar Eli avatar FCP avatar stardiviner avatar Takaaki ISHIKAWA avatar  avatar  avatar

Watchers

 avatar  avatar Théo Tyburn avatar  avatar quarkQuark avatar

org-extra-emphasis's Issues

Markers not revealing when cursor close

Hey !

I really love what you've done with org-extra-emphasis.
Is there a way i can show the marker used when the cursor comes close to the marked up text ? I would like the same behavior as there already is with bold etc when org-hide-emphasis-marker is set to t.

Screenshot_20221005_234152
Screenshot_20221005_234227

org-extra-emphasis-alist markers cancel out evil-surround functionality

I've chosen my alist markers to be !, $, %, &, ^

They work perfectly well as per this package, but when trying to change the characters using evil-surround, it does not work. I get message no such pair found.

I did open an issue on the evil-surround repo, but my instinct tells me it is a bug with this package because the issue is only present with the symbols defined by org-extra-emphasis-alist.

I can look into it myself, but before I do I'd like to find out if anyone more familiar with this package has an idea of what could be causing the trouble

Integration with org-appear, some markers don't hide

I've notice that some markers like =text= and ~text~ don't hide when org-extra-emphasis is toggled, no matter if I force local variables. Also how it is possible to add the new markers to org-appear? Thanks for your work!

Unexpected behaviour in extra emphasis markers' interaction with other markers and each other

The following org code shows a few scenarios where the extra emphasis markers do not behave as expected.

* Org Extra Emphasis Markers
** =!!= and =!@= override bold, italic, etc.
/a   man a plan a canal   panama/
/a !!man a plan a canal!! panama/

/a   man a plan a canal   panama/
/a !@man a plan a canal!@ panama/

** Bold, italic, etc. don't override =!!= or =!@= though
  a *man /a _plan_ a/ canal* panama  
!!a *man /a _plan_ a/ canal* panama!!

  a *man /a _plan_ a/ canal* panama  
!@a *man /a _plan_ a/ canal* panama!@
  
** =!!= and =!@= are mutually incompatible (unlike the screenshot shown in readme)
!!a !@man a plan a canal!@ panama!!
!@a !!man a plan a canal!! panama!@

** Highlight is not shown in =hl-line-mode=
!!a man a plan!! !@a canal panama!@
!!a man a plan!! !@a canal panama!@

This is rendered as:
Screenshot from 2023-02-09 20-14-07
The example illustrates the issues, namely:

  • The extra emphasis faces override the default bold, italic, underline, and other faces instead of complimenting them.
  • The other way around works fine.
  • The yellow highlight and red display faces also override each other (unlike the screenshot shown in the readme).
  • The yellow highlight (but curiously not the red display) is not shown in hl-line-mode

Org-extra-emphasis in fontenc

hi, i wan't use it for export to pdf-latex, but don't use xetatex or lualatex, is it possible to use org-extra-emphasis in fontenc? If it is not possible with the current code, could it be modified to be able to use it?

Add support for inline font size, font weight and font color

An example would be:

!!*20ffffff hello world !!

Note the string after marker !! is the font specification:

 * means font weight bold, 20 means font size is 20, and ffffff means font color is red

The font properties support partial specification. "*20" or "20ffffff" or "*ffffff" are all valid.

Malformed HTML and ODT output with recent versions of Emacs built from `master`

Malformed HTML and ODT output with recent versions of Emacs built from master

While trying the recipe outlined in Use `org-extra-emphasis’ , when you need more Emphasis Markers in Emacs Org mode, I get malformed HTML and ODT outputs.

(custom-set-faces
 '(org-default ((t ( 
                    :background "#fff8ca"
                    :inherit default
                    ))))
 '(org-extra-emphasis ((t ( 
                           :background "#fff8ca"
                           :height 1.5
                           :inherit default
                           :weight bold
                           :width normal
                           ))))
 '(org-extra-emphasis-01 ((t ( 
                              :family "CherryBomb"
                              :foreground "#A53E2D"
                              :inherit org-extra-emphasis
                              :underline t
                              ))))
 '(org-extra-emphasis-02 ((t ( 
                              :family "Eater"
                              :foreground "#EEB97E"
                              :inherit org-extra-emphasis
                              :weight heavy
                              ))))
 '(org-extra-emphasis-03 ((t ( 
                              :family "Diplomata"
                              :foreground "#683231"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-04 ((t ( 
                              :family "Linux Biolinum Keyboard O"
                              :foreground "#353D8B"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-05 ((t ( 
                              :family "Finger Paint"
                              :foreground "#54436E"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-06 ((t ( 
                              :family "Fuzzy Bubbles"
                              :foreground "#D65D8F"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-07 ((t ( 
                              :family "Gloria Hallelujah"
                              :foreground "#E5C494"
                              :inherit org-extra-emphasis
                              :weight extra-bold
                              ))))
 '(org-extra-emphasis-08 ((t ( 
                              :family "Henny Penny"
                              :foreground "#0B9FCF"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-09 ((t ( 
                              :family "Humor Sans"
                              :foreground "#C9564C"
                              :inherit org-extra-emphasis
                              )))))
#+odt_prettify_xml:

#+HTML_HEAD: <style>
#+HTML_HEAD: .textbox { color: #000000; background: #fff8ca; border: 1px solid #000000; padding: 1em;  }
#+HTML_HEAD: </style>

#+begin_textbox
#+begin_center
!!INDIAN FOOD!!
#+end_center

\\

Indian cuisine includes a wide assortment of colors, aromas and
!@flavors!@.

Food from India's northern region is non-vegetarian and less spicy,
using more diary products in dishes. The cuisine of the southern
regions is mostly vegetarian and tends to be !%spicier!%.

Dishes are often flavored with !&SPICES!& like turmeric, coriander,
cumin and tamarind, also known as the "Indian date."

Rice is a staple food of India, and it is served hot as a side
dish. When cooked in broth and flavored with spices, it's called
@%Pilau@%.  When served with chicken, lamb, or vegetables, it's called
@@BIRYANI@@.

Bread is also an essential staple, especially in north.  There are
many varieties of bread.  The most widespread in India is @%ROTI@% (also
known as @&CHAPATI@&), an unleavened round bread made with whole-wheat
flour.

%!DAL%! is typical Indian dish that is creamy and made with lentils and
various spices.  There are many types of %!DAL%!.
#+end_textbox

# Local Variables:
# eval: (buffer-face-mode 1)
# org-hide-emphasis-markers: t
# End:

Option to export as a CSS class instead of an inline style

I'd like certain spans to export to HTML as a CSS class. For example

Org mode @@test@@.

This would render in Emacs as usual, using the face definitions. But then in HTML it would look something like:

Org mode <span class='my-custom-class'>test</span>

This way I can do more with it, in custom CSS definitions, than I can with a simple emacs face. For example I could put a little box around it with a rounded border. Anything from CSS.

Maybe we could have a variable, like org-extra-emphasis-html-span-class-alist that would map the 16 different faces to the class names like "my-custom-class".

Thoughts? Would you consider a pull request / patch to do this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.