forked from mirrors/org-mode
Export: Optionally use <textarea> for example export.
Examples and src block can now be exported as <textarea> elements to HTML if this is desired. See the documentation for more details.
This commit is contained in:
parent
0405dde8ef
commit
ff85ca95db
|
@ -1,5 +1,7 @@
|
|||
2009-01-19 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* (Changes):
|
||||
|
||||
* Makefile (html_manual): Process the split html manual with the
|
||||
new script.
|
||||
|
||||
|
|
|
@ -26,6 +26,15 @@
|
|||
empty except for the colon.
|
||||
|
||||
** Details
|
||||
*** Examples can be exported to HTML as text areas
|
||||
|
||||
You can now specify a =-t= switch to an example or src block,
|
||||
to make it export to HTML as a text area. To change the
|
||||
defaults for height (number of lines in the example) and
|
||||
width of this area (80), use the =-h= and =-w= switches.
|
||||
|
||||
Thanks to Ulf Stegemann for driving this development.
|
||||
|
||||
*** The attachment directory may now be chosen by the user
|
||||
|
||||
Instead of using the automatic, unique directory related to
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2009-01-19 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.texi (Text areas in HTML export): New section.
|
||||
|
||||
2009-01-16 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.texi (Built-in table editor): Remove the descriptio of `C-c
|
||||
|
|
36
doc/org.texi
36
doc/org.texi
|
@ -321,6 +321,7 @@ HTML export
|
|||
* Quoting HTML tags:: Using direct HTML in Org mode
|
||||
* Links:: Transformation of links for HTML
|
||||
* Images in HTML export:: How to insert figures into HTML output
|
||||
* Text areas in HTML export:: An alternative way to show an example
|
||||
* CSS support:: Changing the appearance of the output
|
||||
* Javascript support:: Info and Folding in a web browser
|
||||
|
||||
|
@ -7445,6 +7446,9 @@ If the syntax for the label format conflicts with the language syntax, use a
|
|||
@code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
|
||||
-n -r -l "((%s))"}. See also the variable @code{org-coderef-label-format}.
|
||||
|
||||
HTML export also allows examples to be publishes as text areas, @pxref{Text
|
||||
areas in HTML export}
|
||||
|
||||
@table @kbd
|
||||
@kindex C-c '
|
||||
@item C-c '
|
||||
|
@ -7469,6 +7473,7 @@ formatting like @samp{(ref:label)} at the end of the current line. Then the
|
|||
label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
|
||||
@end table
|
||||
|
||||
|
||||
@node Include files, Tables exported, Literal examples, Markup rules
|
||||
@subheading Include files
|
||||
@cindex include files, markup rules
|
||||
|
@ -7487,8 +7492,8 @@ language for formatting the contents. The markup is optional, if it is not
|
|||
given, the text will be assumed to be in Org mode format and will be
|
||||
processed normally. The include line will also allow additional keyword
|
||||
parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
|
||||
first line and for each following line. For example, to include a file as an
|
||||
item, use
|
||||
first line and for each following line, as well as any options accepted by
|
||||
the selected markup. For example, to include a file as an item, use
|
||||
|
||||
@example
|
||||
#+INCLUDE: "~/snippets/xx" :prefix1 " + " :prefix " "
|
||||
|
@ -7813,6 +7818,7 @@ language, but with additional support for tables.
|
|||
* Quoting HTML tags:: Using direct HTML in Org mode
|
||||
* Links:: Transformation of links for HTML
|
||||
* Images in HTML export:: How to insert figures into HTML output
|
||||
* Text areas in HTML export:: An alternative way to show an example
|
||||
* CSS support:: Changing the appearance of the output
|
||||
* Javascript support:: Info and Folding in a web browser
|
||||
@end menu
|
||||
|
@ -7926,7 +7932,7 @@ If you want to specify attributes for links, you can do so using a special
|
|||
[[./img/a.jpg]]
|
||||
@end example
|
||||
|
||||
@node Images in HTML export, CSS support, Links, HTML export
|
||||
@node Images in HTML export, Text areas in HTML export, Links, HTML export
|
||||
@subsection Images
|
||||
|
||||
@cindex images, inline in HTML
|
||||
|
@ -7950,7 +7956,29 @@ will link to a high resolution version of the image, you could use:
|
|||
@noindent
|
||||
and you could use @code{http} addresses just as well.
|
||||
|
||||
@node CSS support, Javascript support, Images in HTML export, HTML export
|
||||
@node Text areas in HTML export, CSS support, Images in HTML export, HTML export
|
||||
@subsection Text areas
|
||||
|
||||
@cindex text areas, in HTML
|
||||
An alternative way to publish literal code examples in HTML is to use text
|
||||
areas, where the example can even be edited before pasting it into an
|
||||
application. It is triggered by a @code{-t} switch at an @code{example} or
|
||||
@code{src} block. Using this switch disables any options for syntax and
|
||||
label highlighting, and line numbering, which may be present. You may also
|
||||
use @code{-h} and @code{-w} switches to specify the height and width of the
|
||||
text area, which default to the number of lines in the example, and 80,
|
||||
respectively. For example
|
||||
|
||||
@example
|
||||
#+BEGIN_EXAMPLE -t -w 40
|
||||
(defun org-xor (a b)
|
||||
"Exclusive or."
|
||||
(if a (not b) b))
|
||||
#+END_EXAMPLE
|
||||
@end example
|
||||
|
||||
|
||||
@node CSS support, Javascript support, Text areas in HTML export, HTML export
|
||||
@subsection CSS support
|
||||
@cindex CSS, for HTML export
|
||||
@cindex HTML export, CSS
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
2009-01-19 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org-compat.el (org-count-lines): New function.
|
||||
|
||||
* org-exp.el (org-export-format-source-code-or-example): Handle
|
||||
switches related to text areas.
|
||||
|
||||
* org.el (org-activate-footnote-links): Don't allow match inside a
|
||||
link.
|
||||
|
||||
|
|
|
@ -289,6 +289,15 @@ that can be added."
|
|||
(org-no-properties (substring string (or from 0) to))
|
||||
(substring-no-properties string from to)))
|
||||
|
||||
(defun org-count-lines (s)
|
||||
"How many lines in string S?"
|
||||
(let ((start 0) (n 1))
|
||||
(while (string-match "\n" s start)
|
||||
(setq start (match-end 0) n (1+ n)))
|
||||
(if (and (> (length s) 0) (= (aref s (1- (length s))) ?\n))
|
||||
(setq n (1- n)))
|
||||
n))
|
||||
|
||||
(provide 'org-compat)
|
||||
|
||||
;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
|
||||
|
|
|
@ -2361,14 +2361,24 @@ and `+n' for continuing previous numering.
|
|||
Code formatting according to language currently only works for HTML.
|
||||
Numbering lines works for all three major backends (html, latex, and ascii)."
|
||||
(save-match-data
|
||||
(let (num cont rtn named rpllbl keepp fmt)
|
||||
(let (num cont rtn named rpllbl keepp textareap cols rows fmt)
|
||||
(setq opts (or opts "")
|
||||
num (string-match "[-+]n\\>" opts)
|
||||
cont (string-match "\\+n\\>" opts)
|
||||
rpllbl (string-match "-r\\>" opts)
|
||||
keepp (string-match "-k\\>" opts)
|
||||
textareap (string-match "-t\\>" opts)
|
||||
cols (if (string-match "-w[ \t]+\\([0-9]+\\)" opts)
|
||||
(string-to-number (match-string 1 opts))
|
||||
80)
|
||||
rows (if (string-match "-h[ \t]+\\([0-9]+\\)" opts)
|
||||
(string-to-number (match-string 1 opts))
|
||||
(org-count-lines code))
|
||||
fmt (if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts)
|
||||
(match-string 1 opts)))
|
||||
(when (and textareap (eq backend 'html))
|
||||
;; we cannot use numbering or highlighting.
|
||||
(setq num nil cont nil lang nil))
|
||||
(if keepp (setq rpllbl 'keep))
|
||||
(setq rtn code)
|
||||
(when (equal lang "org")
|
||||
|
@ -2408,8 +2418,15 @@ Numbering lines works for all three major backends (html, latex, and ascii)."
|
|||
(setq rtn (replace-match
|
||||
(format "<pre class=\"src src-%s\">\n" lang)
|
||||
t t rtn))))
|
||||
(setq rtn (concat "<pre class=\"example\">\n" rtn "</pre>\n")))
|
||||
(setq rtn (org-export-number-lines rtn 'html 1 1 num cont rpllbl fmt))
|
||||
(if textareap
|
||||
(setq rtn (concat
|
||||
(format "<p>\n<textarea cols=\"%d\" rows=\"%d\" overflow-x:scroll >\n"
|
||||
cols rows)
|
||||
rtn "</textarea>\n</p>\n"))
|
||||
(setq rtn (concat "<pre class=\"example\">\n" rtn "</pre>\n"))))
|
||||
(unless textareap
|
||||
(setq rtn (org-export-number-lines rtn 'html 1 1 num
|
||||
cont rpllbl fmt)))
|
||||
(concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t)) "\n#+END_HTML\n\n"))
|
||||
((eq backend 'latex)
|
||||
(setq rtn (org-export-number-lines rtn 'latex 0 0 num cont rpllbl fmt))
|
||||
|
|
Loading…
Reference in New Issue