├── example
├── example.pdf
├── example.org
└── example.tex
├── CHANGELOG.org
├── README.org
├── LICENSE
└── ox-dnd.el
/example/example.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xeals/emacs-org-dnd/HEAD/example/example.pdf
--------------------------------------------------------------------------------
/CHANGELOG.org:
--------------------------------------------------------------------------------
1 | ** 2019-07-20
2 |
3 | This update brings the package (mostly) in line with version
4 | [[https://github.com/rpgtex/DND-5e-LaTeX-Template/releases/tag/v0.7.0][0.7.0]]
5 | of upstream.
6 |
7 | *** Known Issues
8 |
9 | - No interface provided for the new attack or spell commands
10 | - Map section formatting will probably break when not used as 3rd and 4th level
11 | headings. See [[file:README.org::*Map sections][Map sections]]
12 | - =org-dnd-use-package= must be set before =ox-dnd= is loaded
13 |
14 | *** Breaking Changes
15 |
16 | - Italics are no longer added to quoteboxes automatically.
17 |
18 | *** Deprecated
19 |
20 | - The =:speed= key in a monster attribute is intended for only ground speed. Use
21 | one of the specialised keys =:fly=, =:burrow=, =:climb=, =:swim=, or =:hover=
22 | for other movement speeds
23 | - Setting the heading level, title, etc. options manually is no longer required
24 | (i.e., can remove =#+OPTIONS: H:5 title:nil toc:nil= unless desired)
25 |
26 | *** Bug Fixes
27 |
28 | - generate captions below objects ([[https://github.com/xeals/emacs-org-dnd/commit/4184b14504b1950a1c2cd71d011d772a56fb5c71][4184b145]])
29 | - remove emphasis from =quotebox= ([[https://github.com/xeals/emacs-org-dnd/commit/d0d430225fda7dce8bc424116273b383284e7c77][d0d43022]])
30 | - remove =DND_USE_PACKAGE= from header options ([[https://github.com/xeals/emacs-org-dnd/commit/c195b13cbf8e2f4b52a9fb3d135488b2a7eac205][c195b13c]])
31 | - remove message in monster block ([[https://github.com/xeals/emacs-org-dnd/commit/3f449152249fe3505a74268973310444e1ca3950][3f449152]])
32 | - rename buffers and documentation to remove mentions of Beamer
33 | ([[https://github.com/xeals/emacs-org-dnd/commit/cf28b189b0aad1050acbe036f89ff50b1123113f][cf28b189]])
34 |
35 | *** Features
36 |
37 | - support map sections ([[https://github.com/xeals/emacs-org-dnd/commit/0dd4d75c3593dc9423443cfed870c4f9d8a5bb1a][0dd4d75c]])
38 | - support special movement types with different keywords
39 | ([[https://github.com/xeals/emacs-org-dnd/commit/31a7e0e350d3dcfc59454f501bb1022905a495df][31a7e0e3]])
40 | - add class/package options ([[https://github.com/xeals/emacs-org-dnd/commit/90df1ffbb56e311e85f1118e0652df4088df67c6][90df1ffb]])
41 |
--------------------------------------------------------------------------------
/README.org:
--------------------------------------------------------------------------------
1 | * =emacs-org-dnd=
2 |
3 | Provides an org-mode compatability layer to the
4 | [[https://github.com/evanbergeron/DND-5e-LaTeX-Template][D&D 5e LaTeX
5 | Template]].
6 |
7 | * News
8 |
9 | See [[file:CHANGELOG.org]].
10 |
11 | * Installation
12 |
13 | As much effort as possible has been taken to make creation feel like natural
14 | org-mode markup.
15 |
16 | Follow the instructions to set up the package at the
17 | [[https://github.com/evanbergeron/DND-5e-LaTeX-Template][LaTeX template
18 | repo]].
19 |
20 | Clone this repo somewhere and add it to your emacs load path.
21 |
22 | Add the following to your =.emacs=:
23 |
24 | #+BEGIN_SRC emacs-lisp
25 | (require 'ox-dnd)
26 | #+END_SRC
27 |
28 | * Usage
29 |
30 | Simply add the following to your =.org= file:
31 |
32 | #+BEGIN_SRC org
33 | ,#+LATEX_CLASS: dnd
34 | #+END_SRC
35 |
36 | Each environment in the LaTeX package corresponds to an org-mode block. Each
37 | block is customised using (several) attributes.
38 |
39 | =ox-dnd= provides an org-mode export backend. You can export the buffer as
40 | a PDF file with @@html:@@ l d @@html:@@ (invoking
41 | the org-mode export dispatcher, then =l d=).
42 |
43 | Options are included here. For full usage examples, see
44 | [[file:example/example.org][the example document]]. A sample PDF and tex
45 | output is included in the [[./example][example]] folder.
46 |
47 | ** Additional options
48 |
49 | Package options can be specified in the standard =#+OPTIONS= header. The
50 | following options are added or changed from their default LaTeX export values:
51 |
52 | - =:title= :: Boolean. Disabled by default, as of upstream version 0.7.0 there
53 | is no official styled title.
54 | - =:justified= :: Boolean. Justify column copy (default =t=).
55 | - =:layout= :: Boolean. Controls whether loading the =dnd= LaTeX package also
56 | modifies the document layout (default =t=). Has no effect if
57 | =org-dnd-use-package= is =nil=.
58 | - =:bg= :: String value. Declare how to load background and footer images:
59 | - =full= :: Load both the background and footer images (default).
60 | - =none= :: Remove both the background and footer images.
61 | - =print= :: Load only the footer images.
62 | - =:mtoc= :: Boolean. Use the multi-column table of contents (default =t=).
63 |
64 | ** Customisation
65 |
66 | If you prefer to use the package in your exported file rather than the class
67 | (the recommended option), you can set =org-dnd-use-package= in your =.emacs=
68 | before loading this package:
69 |
70 | #+begin_src emacs-lisp
71 | (setq org-dnd-use-package t)
72 | (require 'ox-dnd)
73 | #+end_src
74 |
75 | ** Comment/paper/quote box
76 |
77 | - =NAME= :: Title of box
78 |
79 | ** Subtitle
80 |
81 | No attributes.
82 |
83 | Heading on first line of block, subtitle on second line of block.
84 |
85 | ** Spell
86 |
87 | - =NAME= :: Name of spell
88 | - =ATTR_SPELL= :: Spell information:
89 | - =:level= :: Spell level
90 | - =:school= :: Spell school (illusion, abjuration, etc.)
91 | - =:range= :: Spell range (include unit; e.g., =5 feet=)
92 | - =:cast= :: Cast time (include unit; e.g., =1 action=)
93 | - =:duration= :: Spell duration (include unit; e.g., =Until dispelled=,
94 | =1 round/level=)
95 | - =:comp= :: Spell components (in full, including information for
96 | material components)
97 |
98 | Block contents are the spell description.
99 |
100 | ** Monster
101 |
102 | - =NAME= :: Name of monster
103 | - =ATTR_MONSTER_INFO= :: Content in the subheader of a monster:
104 | - =:size=
105 | - =:race=
106 | - =:subrace=; optional
107 | - =:alignment=
108 | - =ATTR_MONSTER_BASICS= :: Basic stat block; all optional:
109 | - =:ac= (armor class)
110 | - =:hp= (hit dice; given as dice notation, e.g., 3d8+3)
111 | - =:speed=; for ground speed. For other types of speed, additionally use
112 | =:fly=, =:burrow=, =:climb=, =:swim=, or =:hover=
113 | - =ATTR_MONSTER_STATS= :: Monster stats; modifiers are calculated
114 | automatically; all optional:
115 | - =:con=
116 | - =:str=
117 | - =:dex=
118 | - =:int=
119 | - =:wis=
120 | - =:cha=
121 | - =ATTR_MONSTER_DETAILS= :: Detailed information; all optional:
122 | - =:skills=
123 | - =:saves=
124 | - =:imm= (damage immunities)
125 | - =:res= (damage resistances)
126 | - =:vul= (damage vulnerabilities)
127 | - =:senses= (e.g., darkvision, tremorsense)
128 | - =:langs= (languages)
129 | - =:cr= (challenge rating; experience value calculated automatically)
130 |
131 |
132 | Block contents are the monster skills in the following format:
133 |
134 | #+BEGIN_SRC org
135 | - Skill name :: Effect
136 | - Actions
137 | - Action name :: Effect
138 | - Legendary Actions
139 | - Legendary action name :: Effect
140 | #+END_SRC
141 |
142 | Any entry that appears before the actions header is a passive skill. The blurb
143 | for legendary actions is added automatically. Any number of entries in each
144 | category (skill, action, legendary action) can be added.
145 |
146 | ** Tables
147 |
148 | Tables are formatted the same as regular org-mode tables.
149 |
150 | =NAME= is used only internally (i.e., for referencing). To set a visible
151 | title for a table, use =HEADER=.
152 |
153 | Tables with no =CAPTION= are formatted inline with text and allow wrapping.
154 | Texts with a caption span both columns.
155 |
156 | Tables accept the following attributes through =ATTR_DND=:
157 |
158 | - =:align= :: As with the standard org-mode align attribute, accepts a LaTeX
159 | alignment string. Common are =lX= or =cX= to left- or centre-align the left
160 | column and expand the right column to fill the page column.
161 | - =:color= :: Accepts a color as defined by the LaTeX package. See the
162 | example document for a list of valid colors.
163 |
164 | ** Map sections
165 |
166 | Map sections are automatically from any heading with the =:map:= tag. The
167 | =:map:= tag will not be rendered as tags normally are. Area sections have two
168 | levels (=area= and =subarea=), so any deeper than two nested levels is not
169 | supported.
170 |
171 | NOTE: Things may break in the section if a top-level heading (rather than a
172 | level 2 heading as in the example) is tagged as a map. There should probably be
173 | a fix eventually for this.
174 |
175 | * License
176 |
177 | Licensed under Apache License, Version 2.0
178 | ([[file:LICENSE][LICENSE]] or http://www.apache.org/licenses/LICENSE-2.0).
179 |
180 | ** Contribution
181 |
182 | Unless you explicitly state otherwise, any contribution intentionally
183 | submitted for inclusion in the work by you, as defined in the Apache-2.0
184 | license, shall be licensed as above, without any additional terms or conditions.
185 |
--------------------------------------------------------------------------------
/example/example.org:
--------------------------------------------------------------------------------
1 | #+TITLE: Example
2 | #+LATEX_CLASS: dnd
3 | #+LATEX_HEADER: \usepackage{lipsum}
4 | #+OPTIONS: bg:full justified:nil toc:nil
5 |
6 | * Chapter 1: The Dark \LaTeX
7 |
8 | ** Main Section
9 | \lipsum[2]
10 |
11 | #+BEGIN_QUOTEBOX
12 | As you approach this template you get a sense that the blood and tears of many generations went into its making. A warm feeling welcomes you as you type your first words.
13 | #+END_QUOTEBOX
14 |
15 | *** Fun with boxes
16 | **** Even more fun!
17 |
18 | #+NAME: This Is a Comment Box!
19 | #+BEGIN_COMMENTBOX
20 | A =commentbox= is a box for minimal highlighting of text. It lacks the ornamentation of =paperbox=, but it can handle being broken over a column.
21 | #+END_COMMENTBOX
22 |
23 | #+BEGIN_SUBTITLE
24 | Weapon, +1, +2, or +3
25 | Weapon (any), uncommon (+1), rare (+2), or very rare (+3)
26 | #+END_SUBTITLE
27 | # Need a subtitle
28 |
29 | \lipsum[3]
30 |
31 | #+NAME: Behold, the Paperbox!
32 | #+BEGIN_PAPERBOX
33 | The =paperbox= is used as a sidebar. It does not break over columns and is best used with a figure environment to float it to one corner of the page where the surrounding text can then flow around it.
34 | #+END_PAPERBOX
35 |
36 | #+HEADER: Nice Table
37 | | *Table head* | *Table head* |
38 | | Some value | Some value |
39 | | Some value | Some value |
40 | | Some value | Some value |
41 |
42 | ** Spells
43 |
44 | #+NAME: Beautiful Typesetting
45 | #+ATTR_SPELL: :level 4 :school illusion :range 5 feet :cast 1 action :duration Until dispelled :comp S, M (ink and parchment, which the spell consumes)
46 | #+BEGIN_SPELL
47 | You are able to transform a written message of any length into a beautiful
48 | scroll. All creatures within range that can see the scroll must make a wisdom
49 | saving throw or be charmed by you until the spell ends.
50 |
51 | While the creature is charmed by you, they cannot take their eyes off the
52 | scroll and cannot willingly move away from the scroll. Also, the targets can
53 | make a wisdom saving throw at the end of each of their turns. On a success,
54 | they are no longer charmed.
55 | #+END_SPELL
56 |
57 | \lipsum[2]
58 |
59 | #+NAME: Monster Foo
60 | #+ATTR_MONSTER_INFO: :size medium :race metasyntactic variable :subrace goblinoid :alignment neutral evil
61 | #+ATTR_MONSTER_BASICS: :ac 9 (12 with \emph{mage armor}) :hp 3d8+3 :speed 30 :fly 30
62 | #+ATTR_MONSTER_STATS: :str 12 :dex 8 :con 13 :int 10 :wis 14 :cha 15
63 | #+ATTR_MONSTER_DETAILS: :langs Common, Goblin :senses darkvision 60ft., passive Perception 10 :cr 1
64 | #+BEGIN_MONSTER
65 | - Innate Spellcasting :: Foo's spellcasting ability is Charisma (spell save DC 12, +4 to hit with spell attacks). It can innately cast the following spells, requiring no material components:
66 | - At will :: /misty step/
67 | - 3/day :: /fog cloud/, /rope trick/
68 | - 1/day :: /identify/
69 | - Spellcasting :: Foo is a 3rd-level spellcaster. Its spellcasting ability is Charisma (spell save DC 12, +4 to hit with spell attacks). It has the following sorcerer spells prepared:
70 | - At will :: /blade ward/, /fire bolt/, /light/, /shocking grasp/
71 | - 1st level (4 slots) :: /burning hands/, /mage armor/
72 | - 2nd level (2 slots) :: /scorching ray/
73 | - Actions
74 | - Multiattack :: The foo makes two melee attacks.
75 | - Dagger :: /Melee or Ranged Weapon Attack:/ +3 to hit, reach 5 ft. or range 20/60ft., one target. /Hit:/ \dice{1d4 + 1} piercing damage.
76 | - Flame Tongue Longsword :: /Melee Weapon Attack:/ +3 to hit, reach 5 ft., one target. /Hit:/ \dice{1d4 + 1} slashing damage plus \dice{2d6} fire damage, or \dice{1d10 + 1} slashing damage plus \dice{2d6} fire damage if used with two hands.
77 | - Assassin's Light Crossbow :: /Ranged Weapon Attack:/ +0 to hit, range 80/320 ft., one target. /Hit:/ \dice{1d8} piercing damage, and the target must make a DC 15 Constitution saving throw, taking \dice{7d6} poison damage on a failed save, or half as much damage on a successful one.
78 | #+END_MONSTER
79 |
80 | ** Colors
81 |
82 | This package provides several global color variables to style =commentbox=, =quotebox=, =paperbox=, and =dndtable= environments.
83 |
84 | #+ATTR_DND: :align lX
85 | | *Color* | *Description* |
86 | | =commentboxcolor= | Controls =commentbox= background. |
87 | | =paperboxcolor= | Controls =paperbox= background. |
88 | | =quoteboxcolor= | Controls =quotebox= background. |
89 | | =tablecolor= | Controls background of even =dndtable= rows. |
90 |
91 | See Table [[tab:colors]] for a list of accent colors that match the core books.
92 |
93 | #+NAME: tab:colors
94 | #+CAPTION: Colors supported by this package
95 | #+ATTR_DND: :align XX
96 | | *Color* | *Description* |
97 | | =PhbLightGreen= | Light green used in PHB Part 1 |
98 | | =PhbLightCyan= | Light cyan used in PHB Part 2 |
99 | | =PhbMauve= | Pale purple used in PHB Part 3 |
100 | | =PhbTan= | Light brown used in PHB appendix |
101 | | =DmgLavender= | Pale purple used in DMG Part 1 |
102 | | =DmgCoral= | Orange-pink used in DMG Part 2 |
103 | | =DmgSlateGray= (=DmgSlateGrey=) | Blue-gray used in PHB Part 3 |
104 | | =DmgLilac= | Purple-gray used in DMG appendix |
105 |
106 | - Use =\setthemecolor[]= to set =themecolor=, =commentcolor=, =paperboxcolor=, and =tablecolor= to a specific color.
107 | - Calling =\setthemecolor= without an argument sets those colors to the current =themecolor=.
108 | - =commentbox=, =dndtable=, =paperbox=, and =quoteboxcolor= also accept an optional color argument to set the color for a single instance.
109 |
110 | *** Examples
111 |
112 | **** Using =themecolor=
113 |
114 | #+BEGIN_SRC org :exports none
115 | \setthemecolor[PhbMauve]
116 |
117 | ,#+NAME: Example
118 | ,#+BEGIN_PAPERBOX
119 | \lipsum[2]
120 | ,#+END_PAPERBOX
121 |
122 | \setthemecolor[PhbLightCyan]
123 |
124 | ,#+HEADER: Example
125 | ,#+ATTR_DND: :align cX
126 | | *d8* | *Item* |
127 | | 1 | Small wooden button |
128 | | 2 | Red feather |
129 | | 3 | Human tooth |
130 | | 4 | Vial of green liquid |
131 | | 6 | Tasty biscuit |
132 | | 7 | Broken axe handle |
133 | | 8 | Tarnished silver locket |
134 | #+END_SRC
135 |
136 | \setthemecolor[PhbMauve]
137 |
138 | #+NAME: Example
139 | #+BEGIN_PAPERBOX
140 | \lipsum[2]
141 | #+END_PAPERBOX
142 |
143 | \setthemecolor[PhbLightCyan]
144 |
145 | #+HEADER: Example
146 | #+ATTR_DND: :align cX
147 | | *d8* | *Item* |
148 | | 1 | Small wooden button |
149 | | 2 | Red feather |
150 | | 3 | Human tooth |
151 | | 4 | Vial of green liquid |
152 | | 6 | Tasty biscuit |
153 | | 7 | Broken axe handle |
154 | | 8 | Tarnished silver locket |
155 |
156 | **** Using element color arguments
157 |
158 | #+BEGIN_SRC org :exports none
159 | ,#+ATTR_DND: :align cX :color DmgCoral
160 | | *d8* | *Item* |
161 | | 1 | Small wooden button |
162 | | 2 | Red feather |
163 | | 3 | Human tooth |
164 | | 4 | Vial of green liquid |
165 | | 6 | Tasty biscuit |
166 | | 7 | Broken axe handle |
167 | | 8 | Tarnished silver locket |
168 | #+END_SRC
169 |
170 | #+ATTR_DND: :align cX :color DmgCoral
171 | | *d8* | *Item* |
172 | | 1 | Small wooden button |
173 | | 2 | Red feather |
174 | | 3 | Human tooth |
175 | | 4 | Vial of green liquid |
176 | | 6 | Tasty biscuit |
177 | | 7 | Broken axe handle |
178 | | 8 | Tarnished silver locket |
179 |
180 | ** Map Regions :map:
181 |
182 | The map region commands provides automatic numbering of areas.
183 |
184 | #+BEGIN_SRC org
185 | ,** Map Regions :map:
186 |
187 | ,*** Village of Hommlet
188 |
189 | This is the village of hommlet.
190 |
191 | ,**** Inn of the Welcome Wench
192 |
193 | Inside the village is the inn of the
194 | Welcome Wench.
195 |
196 | ,**** Blacksmith's Forge
197 |
198 | There's a blacksmith in town, too.
199 |
200 | ,*** Foo's Castle
201 |
202 | This is foo's home, a hovel of mud and
203 | sticks.
204 |
205 | ,**** Moat
206 |
207 | This ditch has a board spanning it.
208 |
209 | ,**** Entrance
210 |
211 | A five-foot hole reveals the dirt floor
212 | illuminated by a hole in the roof.
213 | #+END_SRC
214 |
215 | *** Village of Hommlet
216 |
217 | This is the village of hommlet.
218 |
219 | **** Inn of the Welcome Wench
220 |
221 | Inside the village is the inn of the Welcome Wench.
222 |
223 | **** Blacksmith's Forge
224 |
225 | There's a blacksmith in town, too.
226 |
227 | *** Foo's Castle
228 |
229 | This is foo's home, a hovel of mud and sticks.
230 |
231 | **** Moat
232 |
233 | This ditch has a board spanning it.
234 |
235 | **** Entrance
236 |
237 | A five-foot hole reveals the dirt floor illuminated by a hole in the roof.
238 |
--------------------------------------------------------------------------------
/example/example.tex:
--------------------------------------------------------------------------------
1 | % Created 2019-07-16 Tue 22:35
2 | % Intended LaTeX compiler: pdflatex
3 | \documentclass[10pt,twoside,twocolumn,openany,bg=full,nomultitoc]{dndbook}
4 | \usepackage[english]{babel}
5 | \usepackage[utf8]{inputenc}
6 | \usepackage{hyperref}
7 | \usepackage{listings}
8 |
9 | \usepackage{color}
10 | \usepackage{listings}
11 | \usepackage{lipsum}
12 | \date{\today}
13 | \title{Example}
14 | \hypersetup{
15 | pdfauthor={},
16 | pdftitle={Example},
17 | pdfkeywords={},
18 | pdfsubject={},
19 | pdfcreator={Emacs 26.2 (Org mode 9.2.3)},
20 | pdflang={English}}
21 | \begin{document}
22 |
23 |
24 | \chapter{Chapter 1: The Dark \LaTeX}
25 | \label{sec:org70b5135}
26 |
27 | \section{Main Section}
28 | \label{sec:org8815c0e}
29 | \lipsum[2]
30 |
31 | \begin{quotebox}
32 | As you approach this template you get a sense that the blood and tears of many generations went into its making. A warm feeling welcomes you as you type your first words.
33 | \end{quotebox}
34 |
35 | \subsection{Fun with boxes}
36 | \label{sec:org3732cc1}
37 | \subsubsection{Even more fun!}
38 | \label{sec:org2b4450d}
39 |
40 | \begin{commentbox}{This Is a Comment Box!}\label{org943e959}
41 | A \texttt{commentbox} is a box for minimal highlighting of text. It lacks the ornamentation of \texttt{paperbox}, but it can handle being broken over a column.
42 | \end{commentbox}
43 |
44 | \subtitlesection{Weapon, +1, +2, or +3}{Weapon (any), uncommon (+1), rare (+2), or very rare (+3)}
45 |
46 | \lipsum[3]
47 |
48 | \begin{paperbox}[float=!t]{Behold, the Paperbox!}\label{org0a1e264}
49 | The \texttt{paperbox} is used as a sidebar. It does not break over columns and is best used with a figure environment to float it to one corner of the page where the surrounding text can then flow around it.
50 | \end{paperbox}
51 |
52 | \header{Nice Table}
53 | \begin{dndtable}
54 | \textbf{Table head} & \textbf{Table head}\\
55 | Some value & Some value\\
56 | Some value & Some value\\
57 | Some value & Some value\\
58 | \end{dndtable}
59 |
60 | \section{Spells}
61 | \label{sec:orgdc9aff0}
62 |
63 | \begin{spell}{Beautiful Typesetting}{4th-level illusion}{1 action}{5 feet}{S, M (ink and parchment, which the spell consumes)}{Until dispelled}
64 | You are able to transform a written message of any length into a beautiful
65 | scroll. All creatures within range that can see the scroll must make a wisdom
66 | saving throw or be charmed by you until the spell ends.
67 |
68 | While the creature is charmed by you, they cannot take their eyes off the
69 | scroll and cannot willingly move away from the scroll. Also, the targets can
70 | make a wisdom saving throw at the end of each of their turns. On a success,
71 | they are no longer charmed.
72 | \end{spell}
73 |
74 | \lipsum[2]
75 |
76 | \begin{monsterbox}{Monster Foo}
77 | \begin{hangingpar}
78 | \textit{Medium metasyntactic variable (goblinoid), neutral evil}
79 | \end{hangingpar}
80 | \dndline%
81 | \basics[%
82 | armorclass = 9 (12 with \emph{mage armor}),
83 | hitpoints = \dice{3d8+3},
84 | speed = {30 ft., fly 30 ft.},
85 | ]
86 | \dndline%
87 | \stats[%
88 | CON = \stat{13},
89 | STR = \stat{12},
90 | DEX = \stat{8},
91 | INT = \stat{10},
92 | WIS = \stat{14},
93 | CHA = \stat{15},
94 | ]
95 | \dndline%
96 | \details[%
97 | senses = {darkvision 60ft., passive Perception 10},
98 | languages = {Common, Goblin},
99 | challenge = {1},
100 | ]
101 | \dndline
102 | \begin{monsteraction}[Innate Spellcasting]
103 | Foo's spellcasting ability is Charisma (spell save DC 12, +4 to hit with spell attacks). It can innately cast the following spells, requiring no material components:
104 | \end{monsteraction}
105 | \begin{monsteraction}[At will]
106 | \emph{misty step}
107 | \end{monsteraction}
108 | \begin{monsteraction}[3/day]
109 | \emph{fog cloud}, \emph{rope trick}
110 | \end{monsteraction}
111 | \begin{monsteraction}[1/day]
112 | \emph{identify}
113 | \end{monsteraction}
114 | \begin{monsteraction}[Spellcasting]
115 | Foo is a 3rd-level spellcaster. Its spellcasting ability is Charisma (spell save DC 12, +4 to hit with spell attacks). It has the following sorcerer spells prepared:
116 | \end{monsteraction}
117 | \begin{monsteraction}[At will]
118 | \emph{blade ward}, \emph{fire bolt}, \emph{light}, \emph{shocking grasp}
119 | \end{monsteraction}
120 | \begin{monsteraction}[1st level (4 slots)]
121 | \emph{burning hands}, \emph{mage armor}
122 | \end{monsteraction}
123 | \begin{monsteraction}[2nd level (2 slots)]
124 | \emph{scorching ray}
125 | \end{monsteraction}
126 | \monstersection{Actions}
127 | \begin{monsteraction}[Multiattack]
128 | The foo makes two melee attacks.
129 | \end{monsteraction}
130 | \begin{monsteraction}[Dagger]
131 | \emph{Melee or Ranged Weapon Attack:} +3 to hit, reach 5 ft. or range 20/60ft., one target. \emph{Hit:} \dice{1d4 + 1} piercing damage.
132 | \end{monsteraction}
133 | \begin{monsteraction}[Flame Tongue Longsword]
134 | \emph{Melee Weapon Attack:} +3 to hit, reach 5 ft., one target. \emph{Hit:} \dice{1d4 + 1} slashing damage plus \dice{2d6} fire damage, or \dice{1d10 + 1} slashing damage plus \dice{2d6} fire damage if used with two hands.
135 | \end{monsteraction}
136 | \begin{monsteraction}[Assassin's Light Crossbow]
137 | \emph{Ranged Weapon Attack:} +0 to hit, range 80/320 ft., one target. \emph{Hit:} \dice{1d8} piercing damage, and the target must make a DC 15 Constitution saving throw, taking \dice{7d6} poison damage on a failed save, or half as much damage on a successful one.
138 | \end{monsteraction}
139 | \end{monsterbox}
140 |
141 | \section{Colors}
142 | \label{sec:org523ac5a}
143 |
144 | This package provides several global color variables to style \texttt{commentbox}, \texttt{quotebox}, \texttt{paperbox}, and \texttt{dndtable} environments.
145 |
146 | \begin{dndtable}[lX]
147 | \textbf{Color} & \textbf{Description}\\
148 | \texttt{commentboxcolor} & Controls \texttt{commentbox} background.\\
149 | \texttt{paperboxcolor} & Controls \texttt{paperbox} background.\\
150 | \texttt{quoteboxcolor} & Controls \texttt{quotebox} background.\\
151 | \texttt{tablecolor} & Controls background of even \texttt{dndtable} rows.\\
152 | \end{dndtable}
153 |
154 | See Table \ref{tab:org93502e7} for a list of accent colors that match the core books.
155 |
156 | \begin{table*}[htbp]
157 |
158 | \begin{dndtable}[XX]
159 | \textbf{Color} & \textbf{Description}\\
160 | \texttt{PhbLightGreen} & Light green used in PHB Part 1\\
161 | \texttt{PhbLightCyan} & Light cyan used in PHB Part 2\\
162 | \texttt{PhbMauve} & Pale purple used in PHB Part 3\\
163 | \texttt{PhbTan} & Light brown used in PHB appendix\\
164 | \texttt{DmgLavender} & Pale purple used in DMG Part 1\\
165 | \texttt{DmgCoral} & Orange-pink used in DMG Part 2\\
166 | \texttt{DmgSlateGray} (\texttt{DmgSlateGrey}) & Blue-gray used in PHB Part 3\\
167 | \texttt{DmgLilac} & Purple-gray used in DMG appendix\\
168 | \end{dndtable}
169 | \caption{\label{tab:org93502e7}
170 | Colors supported by this package}
171 |
172 | \end{table*}
173 |
174 | \begin{itemize}
175 | \item Use \texttt{\textbackslash{}setthemecolor[]} to set \texttt{themecolor}, \texttt{commentcolor}, \texttt{paperboxcolor}, and \texttt{tablecolor} to a specific color.
176 | \item Calling \texttt{\textbackslash{}setthemecolor} without an argument sets those colors to the current \texttt{themecolor}.
177 | \item \texttt{commentbox}, \texttt{dndtable}, \texttt{paperbox}, and \texttt{quoteboxcolor} also accept an optional color argument to set the color for a single instance.
178 | \end{itemize}
179 |
180 | \subsection{Examples}
181 | \label{sec:orgc47216d}
182 |
183 | \subsubsection{Using \texttt{themecolor}}
184 | \label{sec:org547c3ec}
185 |
186 | \setthemecolor[PhbMauve]
187 |
188 | \begin{paperbox}[float=!t]{Example}\label{org72655cf}
189 | \lipsum[2]
190 | \end{paperbox}
191 |
192 | \setthemecolor[PhbLightCyan]
193 |
194 | \header{Example}
195 | \begin{dndtable}[cX]
196 | \textbf{d8} & \textbf{Item}\\
197 | 1 & Small wooden button\\
198 | 2 & Red feather\\
199 | 3 & Human tooth\\
200 | 4 & Vial of green liquid\\
201 | 6 & Tasty biscuit\\
202 | 7 & Broken axe handle\\
203 | 8 & Tarnished silver locket\\
204 | \end{dndtable}
205 |
206 | \subsubsection{Using element color arguments}
207 | \label{sec:orgfdc6e2c}
208 |
209 | \begin{dndtable}[cX][DmgCoral]
210 | \textbf{d8} & \textbf{Item}\\
211 | 1 & Small wooden button\\
212 | 2 & Red feather\\
213 | 3 & Human tooth\\
214 | 4 & Vial of green liquid\\
215 | 6 & Tasty biscuit\\
216 | 7 & Broken axe handle\\
217 | 8 & Tarnished silver locket\\
218 | \end{dndtable}
219 |
220 | \section{Map Regions}
221 | \label{sec:orgaf7e525}
222 |
223 | The map region commands provides automatic numbering of areas.
224 |
225 | \begin{verbatim}
226 | ** Map Regions :map:
227 |
228 | *** Village of Hommlet
229 |
230 | This is the village of hommlet.
231 |
232 | **** Inn of the Welcome Wench
233 |
234 | Inside the village is the inn of the
235 | Welcome Wench.
236 |
237 | **** Blacksmith's Forge
238 |
239 | There's a blacksmith in town, too.
240 |
241 | *** Foo's Castle
242 |
243 | This is foo's home, a hovel of mud and
244 | sticks.
245 |
246 | **** Moat
247 |
248 | This ditch has a board spanning it.
249 |
250 | **** Entrance
251 |
252 | A five-foot hole reveals the dirt floor
253 | illuminated by a hole in the roof.
254 | \end{verbatim}
255 |
256 | \area{Village of Hommlet}
257 | \label{sec:org5ba5a97}
258 |
259 | This is the village of hommlet.
260 |
261 | \subarea{Inn of the Welcome Wench}
262 | \label{sec:org93b54e4}
263 |
264 | Inside the village is the inn of the Welcome Wench.
265 |
266 | \subarea{Blacksmith's Forge}
267 | \label{sec:org8f38325}
268 |
269 | There's a blacksmith in town, too.
270 |
271 | \area{Foo's Castle}
272 | \label{sec:orgad26bbf}
273 |
274 | This is foo's home, a hovel of mud and sticks.
275 |
276 | \subarea{Moat}
277 | \label{sec:org77e64f2}
278 |
279 | This ditch has a board spanning it.
280 |
281 | \subarea{Entrance}
282 | \label{sec:org99a7b06}
283 |
284 | A five-foot hole reveals the dirt floor illuminated by a hole in the roof.
285 | \end{document}
286 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2018 Alex Smith
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/ox-dnd.el:
--------------------------------------------------------------------------------
1 | ;;; ox-dnd.el --- Write D&D homebrew sheets using org-mode
2 |
3 | ;; Copyright (C) 2019 Alex Smith
4 |
5 | ;; Author: Alex Smith
6 | ;; URL: https://github.com/xeals/emacs-org-dnd
7 |
8 | (require 'ox-latex)
9 |
10 | (defgroup org-dnd nil
11 | "Group for customising the org-mode D&D LaTeX export backend.")
12 |
13 | (defcustom org-dnd-use-package nil
14 | "Use the `book' LaTeX class when exporting a D&D org-mode file
15 | instead of the `dndbook' class."
16 | :group 'org-dnd)
17 |
18 | (unless (assoc "dnd" org-latex-classes)
19 | (add-to-list
20 | 'org-latex-classes
21 | `("dnd"
22 | ,(concat
23 | (format
24 | "\\documentclass[10pt,twoside,twocolumn,openany[CO]]{%s}
25 | [NO-DEFAULT-PACKAGES]
26 | \\usepackage[AUTO]{babel}
27 | \\usepackage[utf8]{inputenc}
28 | \\usepackage{hyperref}"
29 | (if org-dnd-use-package "book" "dndbook"))
30 | (when org-dnd-use-package "\\n\\usepackage{dnd}"))
31 | ("\\chapter{%s}" . "\\chapter*{%s}")
32 | ("\\section{%s}" . "\\section*{%s}")
33 | ("\\subsection{%s}" . "\\subsection*{%s}")
34 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
35 |
36 | (defun ordinal (n)
37 | (let ((str (if (numberp n) (number-to-string n) n)))
38 | (concat str
39 | (pcase (last str)
40 | ("1" "st")
41 | ("2" "nd")
42 | ("3" "rd")
43 | (_ "th")))))
44 |
45 | (defun org-dnd--spell-level (level school)
46 | (org-trim
47 | (format "%s%s"
48 | (if level
49 | (concat (ordinal level) "-level ")
50 | "")
51 | (or (downcase school) ""))))
52 |
53 | (defun org-dnd-spell (spell contents info)
54 | "Transcode a SPELL element from Org to D&D LaTeX.
55 | CONTENTS holds the contents of the block. INFO is a plist holding
56 | contextual information."
57 | (let ((name (org-element-property :name spell))
58 | (level (org-export-read-attribute :attr_spell spell :level))
59 | (school (org-export-read-attribute :attr_spell spell :school))
60 | (ct (org-export-read-attribute :attr_spell spell :cast))
61 | (range (org-export-read-attribute :attr_spell spell :range))
62 | (mats (org-export-read-attribute :attr_spell spell :comp))
63 | (dur (org-export-read-attribute :attr_spell spell :duration)))
64 | (concat "\\begin{spell}"
65 | (format "{%s}" (or name ""))
66 | (format "{%s}" (org-dnd--spell-level level school))
67 | (format "{%s}" (or ct ""))
68 | (format "{%s}" (or range ""))
69 | (format "{%s}" (or mats ""))
70 | (format "{%s}\n" (or dur ""))
71 | contents
72 | "\\end{spell}")))
73 |
74 | (defun org-dnd--subtitle-block (subtitle contents info)
75 | "Transcode a SUBTITLE-BLOCK element to D&D LaTeX.
76 | CONTENTS holds the contents of the block. INFO is a plist holding
77 | contextual information."
78 | (let ((content (split-string contents "\n" t nil)))
79 | (format "\\subtitlesection{%s}{%s}"
80 | (car content)
81 | (car (cdr content)))))
82 |
83 | (defun org-dnd--extract-actions (content)
84 | (org-trim
85 | (replace-regexp-in-string
86 | "\n+"
87 | "\n"
88 | (replace-regexp-in-string
89 | "|"
90 | "\n"
91 | (replace-regexp-in-string
92 | "\\\\\\(begin\\|end\\){description}"
93 | ""
94 | (replace-regexp-in-string
95 | "\\\\item\\[{\\([^}]*\\)}] \\(.+?\\)|\\\\"
96 | "\\\\begin{monsteraction}[\\1]|\\2|\\\\end{monsteraction}|\\\\"
97 | (replace-regexp-in-string
98 | "\\\\item\\[{\\([^}]*\\)}] \\(.+?\\)|\\\\"
99 | "\\\\begin{monsteraction}[\\1]|\\2|\\\\end{monsteraction}|\\\\"
100 | (replace-regexp-in-string
101 | "\\\\item \\([^|]*\\)"
102 | "\\\\monstersection{\\1}"
103 | (replace-regexp-in-string "\n" "|" content)))))))))
104 |
105 | (defun org-dnd--add-legendary-action-text (name content)
106 | (let ((nm (downcase name)))
107 | (replace-regexp-in-string
108 | "{Legendary Actions}"
109 | (format "{Legendary Actions}\nThe %s can take 3 legendary actions, choosing from the options below. Only one legendary action option can be used at a time and only at the end of another creature's turn. The %s regains spent legendary actions at the start of its turn.\n" nm nm)
110 | content)))
111 |
112 | (defun org-dnd-monsterbox (monster contents info)
113 | "Transcode a monster box from Org to a D&D LaTeX monsterbox.
114 | CONTENTS holds the contents of the table. INFO is a plist holding
115 | contextual information."
116 | (let ((name (org-element-property :name monster)))
117 | (concat
118 | "\\begin{monsterbox}"
119 | (if name (format "{%s}" name) "")
120 | "\n"
121 | ;; Race and info
122 | (let ((size (org-export-read-attribute :attr_monster_info monster :size))
123 | (race (org-export-read-attribute :attr_monster_info monster :race))
124 | (subrace (org-export-read-attribute :attr_monster_info monster :subrace))
125 | (alignment (org-export-read-attribute :attr_monster_info monster :alignment)))
126 | (when (and size race alignment)
127 | (concat
128 | "\\begin{hangingpar}\n\\textit{"
129 | (format "%s %s" (capitalize size) race)
130 | (when subrace (format " (%s)" subrace))
131 | (format ", %s" alignment)
132 | "}\n\\end{hangingpar}\n")))
133 | "\\dndline%\n"
134 | ;; Basics
135 | (let ((ac (org-export-read-attribute :attr_monster_basics monster :ac))
136 | (hp (org-export-read-attribute :attr_monster_basics monster :hp))
137 | (speed (org-export-read-attribute :attr_monster_basics monster :speed))
138 | ;; Special speed attributes
139 | (burrow (org-export-read-attribute :attr_monster_basics monster :burrow))
140 | (climb (org-export-read-attribute :attr_monster_basics monster :climb))
141 | (fly (org-export-read-attribute :attr_monster_basics monster :fly))
142 | (hover (org-export-read-attribute :attr_monster_basics monster :hover))
143 | (swim (org-export-read-attribute :attr_monster_basics monster :swim)))
144 | (concat "\\basics[%\n"
145 | (format "armorclass = %s,\n" (or ac 0))
146 | (format "hitpoints = \\dice{%s},\n" (or hp 0))
147 | (format "speed = {%s ft." (or speed 0))
148 | (when burrow (format ", burrow %s ft." burrow))
149 | (when climb (format ", climb %s ft." climb))
150 | (when fly (format ", fly %s ft." fly))
151 | (when hover (format ", fly %s ft. (hover)" hover))
152 | (when swim (format ", swim %s ft." swim))
153 | "},\n]\n"))
154 | "\\dndline%\n"
155 | ;; Stats
156 | (let ((con (org-export-read-attribute :attr_monster_stats monster :con))
157 | (str (org-export-read-attribute :attr_monster_stats monster :str))
158 | (dex (org-export-read-attribute :attr_monster_stats monster :dex))
159 | (int (org-export-read-attribute :attr_monster_stats monster :int))
160 | (wis (org-export-read-attribute :attr_monster_stats monster :wis))
161 | (cha (org-export-read-attribute :attr_monster_stats monster :cha)))
162 | (concat "\\stats[%\n"
163 | (format "CON = \\stat{%s},\n" (or con 10))
164 | (format "STR = \\stat{%s},\n" (or str 10))
165 | (format "DEX = \\stat{%s},\n" (or dex 10))
166 | (format "INT = \\stat{%s},\n" (or int 10))
167 | (format "WIS = \\stat{%s},\n" (or wis 10))
168 | (format "CHA = \\stat{%s},\n" (or cha 10))
169 | "]\n"))
170 | "\\dndline%\n"
171 | ;; Details
172 | (let ((skills (org-export-read-attribute :attr_monster_details monster :skills))
173 | (saves (org-export-read-attribute :attr_monster_details monster :saves))
174 | (imm (org-export-read-attribute :attr_monster_details monster :imm))
175 | (res (org-export-read-attribute :attr_monster_details monster :res))
176 | (vul (org-export-read-attribute :attr_monster_details monster :vul))
177 | (senses (org-export-read-attribute :attr_monster_details monster :senses))
178 | (langs (org-export-read-attribute :attr_monster_details monster :langs))
179 | (cr (org-export-read-attribute :attr_monster_details monster :cr)))
180 | (concat "\\details[%\n"
181 | (when skills (format "skills = {%s},\n" skills))
182 | (when saves (format "savingthrows = {%s},\n" saves))
183 | (when imm (format "conditionimmunities = {%s},\n" imm))
184 | (when res (format "damageresistances = {%s},\n" res))
185 | (when vul (format "damagevulnerabilities = {%s},\n" vul))
186 | (when senses (format "senses = {%s},\n" senses))
187 | (when langs (format "languages = {%s},\n" langs))
188 | (format "challenge = {%s},\n" (or cr 0))
189 | "]\n"))
190 | "\\dndline\n"
191 | ;; Abilities and actions
192 | (org-dnd--add-legendary-action-text
193 | name
194 | (org-dnd--extract-actions contents))
195 | "\n\\end{monsterbox}")))
196 |
197 | (defun org-dnd-headline (headline contents info)
198 | "Transcode a HEADLINE element from Org to LaTeX.
199 | CONTENTS holds the contents of the headline. INFO is a plist
200 | holding contextual information."
201 | (let ((text (org-latex-headline headline contents info))
202 | (tags (org-element-property :tags headline)))
203 | (if (member "map" tags)
204 | (progn
205 | (org-element-put-property headline :tags (remove "map" tags))
206 | (replace-regexp-in-string
207 | "subsection{"
208 | "area{"
209 | (org-latex-headline headline contents info)))
210 | (org-latex-headline headline contents info))))
211 |
212 | ;; HACK There has to be an easier way to add the package options as a derived
213 | ;; LaTeX backend.
214 | (defun org-dnd-template (contents info)
215 | "Return complete document string after LaTeX conversion.
216 | CONTENTS is the transcoded contents string. INFO is a plist
217 | holding export options."
218 | (defun bool (b) (if b "true" "false"))
219 | (let* ((just (plist-get info :justified))
220 | (layout (plist-get info :layout))
221 | (bg (plist-get info :with-bg))
222 | (multitoc (plist-get info :with-multitoc))
223 | (class-options
224 | (concat
225 | (when just "justified,")
226 | (when bg (format "bg=%s," bg))
227 | (when (and org-dnd-use-package layout)
228 | (format "layout=%s," (bool org-dnd-use-package)))
229 | (unless multitoc "nomultitoc"))))
230 | (let ((body (org-latex-template contents info)))
231 | (replace-regexp-in-string
232 | "\\[CO\\]"
233 | (concat "," (replace-regexp-in-string
234 | ",$" ""
235 | class-options))
236 | body t))))
237 |
238 | (defun org-dnd-special-block (special-block contents info)
239 | "Transcode a SPECIAL-BLOCK element from Org to D&D LaTeX.
240 | CONTENTS holds the contents of the block. INFO is a plist holding
241 | contextual information."
242 | (let ((type (downcase (org-element-property :type special-block)))
243 | (title (or (org-element-property :name special-block) "")))
244 | (pcase type
245 | ("commentbox"
246 | (concat (format "\\begin{%s}{%s}" type title)
247 | (org-latex--caption/label-string special-block info)
248 | contents
249 | (format "\\end{%s}" type)))
250 | ("paperbox"
251 | (concat (format "\\begin{%s}[float=!t]{%s}" type title)
252 | (org-latex--caption/label-string special-block info)
253 | contents
254 | (format "\\end{%s}\n" type)))
255 | ("quotebox"
256 | (concat (format "\\begin{%s}\n" type)
257 | contents
258 | (format "\\end{%s}" type)))
259 | ("spell" (org-dnd-spell special-block contents info))
260 | ("subtitle" (org-dnd--subtitle-block special-block contents info))
261 | ("monster" (org-dnd-monsterbox special-block contents info))
262 | (_ (org-latex-special-block special-block contents info)))))
263 |
264 | (defun org-dnd-table (table contents info)
265 | "Transcode a table from Org to a D&D LaTeX table.
266 | CONTENTS holds the contents of the table. INFO is a plist holding
267 | contextual information."
268 | (let ((header (car (org-element-property :header table)))
269 | (align (org-export-read-attribute :attr_dnd table :align))
270 | (color (org-export-read-attribute :attr_dnd table :color))
271 | (separate (org-export-read-attribute :attr_dnd table :separate)))
272 | (format
273 | "%s%s"
274 | (if header (format "\\header{%s}\n" header) "")
275 | (replace-regexp-in-string
276 | "begin{tabular.*"
277 | (format "begin{dndtable}%s%s"
278 | (if align (format "[%s]" align) "")
279 | (if color (format "[%s]" color) ""))
280 | (replace-regexp-in-string
281 | "end{tabular}"
282 | "end{dndtable}"
283 | (replace-regexp-in-string
284 | "{table}"
285 | "{table*}"
286 | (replace-regexp-in-string
287 | "\\\\\\(begin\\|end\\){center}\n?"
288 | ""
289 | (replace-regexp-in-string
290 | "\\\\centering"
291 | ""
292 | (replace-regexp-in-string
293 | "\\\\hline"
294 | (if (not separate) ""
295 | (format "\\\\end{dndtable}\n\\\\begin{dndtable}%s%s"
296 | (if align (format "[%s]" align) "")
297 | (if color (format "[%s]" color) "")))
298 | (org-latex-table table contents info))))))))))
299 |
300 | (org-export-define-derived-backend 'dnd 'latex
301 | :menu-entry
302 | '(?l 1
303 | ((?d "As PDF file (D&D)" org-dnd-export-to-pdf)
304 | (?D "As PDF file and open (D&D)"
305 | (lambda (a s v b)
306 | (if a (org-dnd-export-to-pdf t s v b)
307 | (org-open-file (org-dnd-export-to-pdf nil s v b)))))))
308 | :options-alist
309 | '((:justified nil "justified" t t)
310 | (:layout nil "layout" t nil)
311 | (:with-bg nil "bg" "full" t)
312 | (:with-multitoc nil "mtoc" nil t)
313 | (:with-title nil "title" nil t)
314 | (:headline-levels nil "H" 5 t)
315 | (:latex-caption-above nil nil nil))
316 | :translate-alist '((headline . org-dnd-headline)
317 | (template . org-dnd-template)
318 | (table . org-dnd-table)
319 | (special-block . org-dnd-special-block)))
320 |
321 | ;;;###autoload
322 | (defun org-dnd-export-as-latex
323 | (&optional async subtreep visible-only body-only ext-plist)
324 | "Export current buffer as a D&D buffer.
325 |
326 | If narrowing is active in the current buffer, only export its
327 | narrowed part.
328 |
329 | If a region is active, export that region.
330 |
331 | A non-nil optional argument ASYNC means the process should happen
332 | asynchronously. The resulting buffer should be accessible
333 | through the `org-export-stack' interface.
334 |
335 | When optional argument SUBTREEP is non-nil, export the sub-tree
336 | at point, extracting information from the headline properties
337 | first.
338 |
339 | When optional argument VISIBLE-ONLY is non-nil, don't export
340 | contents of hidden elements.
341 |
342 | When optional argument BODY-ONLY is non-nil, only write code
343 | between \"\\begin{document}\" and \"\\end{document}\".
344 |
345 | EXT-PLIST, when provided, is a property list with external
346 | parameters overriding Org default settings, but still inferior to
347 | file-local settings.
348 |
349 | Export is done in a buffer named \"*Org D&D Export*\", which
350 | will be displayed when `org-export-show-temporary-export-buffer'
351 | is non-nil.
352 |
353 | Sourced from ox-beamer."
354 | (interactive)
355 | (org-export-to-buffer 'dnd "*Org D&D Export*"
356 | async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
357 |
358 | ;;;###autoload
359 | (defun org-dnd-export-to-latex
360 | (&optional async subtreep visible-only body-only ext-plist)
361 | "Export current buffer as a D&D LaTeX file.
362 |
363 | If narrowing is active in the current buffer, only export its
364 | narrowed part.
365 |
366 | If a region is active, export that region.
367 |
368 | A non-nil optional argument ASYNC means the process should happen
369 | asynchronously. The resulting file should be accessible through
370 | the `org-export-stack' interface.
371 |
372 | When optional argument SUBTREEP is non-nil, export the sub-tree
373 | at point, extracting information from the headline properties
374 | first.
375 |
376 | When optional argument VISIBLE-ONLY is non-nil, don't export
377 | contents of hidden elements.
378 |
379 | When optional argument BODY-ONLY is non-nil, only write code
380 | between \"\\begin{document}\" and \"\\end{document}\".
381 |
382 | EXT-PLIST, when provided, is a property list with external
383 | parameters overriding Org default settings, but still inferior to
384 | file-local settings.
385 |
386 | Return PDF file's name.
387 |
388 | Sourced from ox-beamer."
389 | (interactive)
390 | (let ((file (org-export-output-file-name ".tex" subtreep)))
391 | (org-export-to-file 'dnd file
392 | async subtreep visible-only body-only ext-plist)))
393 |
394 | ;;;###autoload
395 | (defun org-dnd-export-to-pdf
396 | (&optional async subtreep visible-only body-only ext-plist)
397 | "Export current buffer as a Beamer presentation (PDF).
398 |
399 | If narrowing is active in the current buffer, only export its
400 | narrowed part.
401 |
402 | If a region is active, export that region.
403 |
404 | A non-nil optional argument ASYNC means the process should happen
405 | asynchronously. The resulting file should be accessible through
406 | the `org-export-stack' interface.
407 |
408 | When optional argument SUBTREEP is non-nil, export the sub-tree
409 | at point, extracting information from the headline properties
410 | first.
411 |
412 | When optional argument VISIBLE-ONLY is non-nil, don't export
413 | contents of hidden elements.
414 |
415 | When optional argument BODY-ONLY is non-nil, only write code
416 | between \"\\begin{document}\" and \"\\end{document}\".
417 |
418 | EXT-PLIST, when provided, is a property list with external
419 | parameters overriding Org default settings, but still inferior to
420 | file-local settings.
421 |
422 | Return PDF file's name.
423 |
424 | Sourced from ox-beamer."
425 | (interactive)
426 | (let ((file (org-export-output-file-name ".tex" subtreep)))
427 | (org-export-to-file 'dnd file
428 | async subtreep visible-only body-only ext-plist
429 | (lambda (file) (org-latex-compile file)))))
430 |
431 | (provide 'ox-dnd)
432 |
433 | ;;; ox-dnd.el ends here
434 |
--------------------------------------------------------------------------------