Hot answers tagged

21 votes
Accepted

How prettify (newlines and indentation) an optimized HTML/JS file?

You can use the built-in sgml-mode for this. M-x sgml-mode - Enable the sgml-mode major mode so that sgml-pretty-print command auto-loads. C-x h - Select the whole buffer. M-x sgml-pretty-print To ...
Kaushal Modi's user avatar
20 votes
Accepted

Org mode - Parsing rich HTML directly when pasting?

is it feasible to make one? Since this is emacs, yes. My approach is to use a 3rd party tools that can take HTML and convert to plain text or even directly to Org format. I think this is an ugly ...
mankoff's user avatar
  • 4,066
19 votes
Accepted

How to include rendered HTML in org mode?

If you want to include literal HTML in your org file, and have it exported only when you export to HTML, use an export block: #+BEGIN_EXPORT html <br> <h2>This is the footer.</h2> &...
NickD's user avatar
  • 25.9k
15 votes
Accepted

HTML mode that closes tags

With the default HTML mode as of Emacs 24.4, you can get the same behavior as Sublime Text (automatic insertion of the closing tag if you type </) by putting the following line in your init file: (...
Gilles 'SO- stop being evil''s user avatar
12 votes
Accepted

How do I export an ORG file to an interactive HTML site?

What you are looking for is org-info.js, a JavaScript library to be used in conjunction with HTML files generated from Org. This library adds support for folding, navigation, etc. Take a look at ...
glucas's user avatar
  • 20.1k
11 votes
Accepted

automatically move to n-th character on line after each C-n or C-p

set-goal-column might be what you're looking for : set-goal-column is an interactive compiled Lisp function in `simple.el'. It is bound to C-x C-n. (set-goal-column ARG) Set the current horizontal ...
YoungFrog's user avatar
  • 3,466
10 votes
Accepted

no html/jsx indentation in jsx-mode

This is a known issue and as of now, it has not been fixed. I've decided to forego jsx-mode for this reason and just use web-mode. It has support for JSX and is better suited for mixed content files. ...
flooose's user avatar
  • 501
9 votes

Markdown preview in Emacs using pandoc

After a while, I found the answer myself: In a nutshell: Use a combination of Eww and markdown mode, and configure markdown mode to render markdown with pandoc. Alas, easier said than done. Update ...
henning's user avatar
  • 48
9 votes
Accepted

Org-mode external links not working when exported to HTML

The string behind :: is actually a search. In this context one understands the relevant comment in the source code of the function org-html-link in the library file ox-html.el (org 8.2.5). It says: ...
Tobias's user avatar
  • 32.1k
9 votes

no html/jsx indentation in jsx-mode

FYI for anyone else who comes across this issue, this is because this jsx-mode project is not made to edit Facebook's React JSX templates but rather this other compiled javascript language also called ...
Victor Quinn's user avatar
6 votes
Accepted

HTML editing with preview

You have some options: http://wikemacs.org/wiki/Markdown#Impatient-mode the best for html looking to be impatient-mode, it allows to see the changes in your browser while you type. After ...
Ehvince's user avatar
  • 1,081
6 votes
Accepted

Emacs script to indent files from the command line

@glucas's answer is correct in its diagnosis, but has a minor problem (you want the 0th element of argv) and is incomplete. Here is a more complete example: #!/usr/bin/env -S emacs --script (find-...
NickD's user avatar
  • 25.9k
5 votes
Accepted

Editing HTML structurally

Tagedit is what you want. From the README: tagedit-forward-slurp-tag moves the next sibling into this tag. tagedit-forward-barf-tag moves the last child out of this tag. tagedit-raise-tag replaces ...
clemera's user avatar
  • 3,391
5 votes
Accepted

How can I generate the <abbr> HTML tag from org-mode?

I guess the simplest way is to define a macro in your orgmode file with: #+MACRO: abbr @@html:<abbr title="$1">$2</abbr>@@ You can then add an abbr in your text with: {{{abbr(Definition,...
Plankalkül's user avatar
5 votes

Do not add TITLE as heading to body when exporting org file

You can hide the title by providing the appropriate CSS setting. For example, add this line to your file (and hit C-c C-c to activate the change): #+HTML_HEAD: <style type="text/css"> <!--/*...
JeanPierre's user avatar
  • 7,273
5 votes
Accepted

Embed Image as Base64 on HTML export from Orgmode

See http://kitchingroup.cheme.cmu.edu/blog/2015/05/09/Another-approach-to-embedding-org-source-in-html/. You may also find this: https://github.com/KitchinHUB/kitchingroup-66/blob/master/manuscript....
John Kitchin's user avatar
  • 11.5k
5 votes
Accepted

Center image in GitHub's README.org

You can embed "raw" html as follows: <p align="center"><img src="images/wim-128.png" /></p> When displayed on GitHub.com, for some reason org-mode's image styling directives are ...
Alex Shroyer's user avatar
5 votes

Center image in GitHub's README.org

To center with CSS, you need to use margin-left: auto; and margin-right: auto; try this #+ATTR_HTML: :style margin-left: auto; margin-right: auto; [[/path/to/img.png]]
Xah Lee's user avatar
  • 1,746
5 votes
Accepted

Org-Mode: Exclude specific code line from html export

Take a look at the prologue header argument for Babel source blocks. You can use it to prepend some text to a code block prior to execution, and, like any other header argument, it isn't included in ...
Aaron Miller's user avatar
5 votes
Accepted

siunitx, MathJax, org-mode and html export

You have to set the variable org-html-mathjax-template appropriately. Assuming you are using the default configuration, loading mathjax from cdn.mathjax.org, then the following setting (which loads ...
NickD's user avatar
  • 25.9k
5 votes

HTML mode that closes tags

Install web-mode, http://web-mode.org/. It is the most complete mode for web pages and does contain what it calls HTML tag auto closing.
Heikki's user avatar
  • 2,931
5 votes
Accepted

How to use Org KEYWORD values within exported body?

Org mode defines macros for these things. Try: #+TITLE: Some Title #+AUTHOR: Foo Bar #+DATE: 2021-08-21 * some headline This works: - author's name: {{{author}}} - date: {{{date}}} See the &...
NickD's user avatar
  • 25.9k
5 votes

html-mode: publish to browser and jump to cursor location

One way is using an elisp function and a temporary anchor in the html: Surround the line where cursor is with an anchor <a name='CursorPosition'> Use browse-url-firefox (or preferred browser) ...
c_48's user avatar
  • 351
4 votes
Accepted

Embbed html/javascript in org-mode html export

#+INCLUDE: "someFile.html" html should result in an included rendered version of the html file and not just "quote the source file".
CantrianBear's user avatar
4 votes
Accepted

Emacs picking the wrong browser

Well, in a sense sensible-browser is a system default browser:-) I believe that you need to use the update-alternatives system to set that system default. As to why Org mode is using sensible-...
Bob Uhl's user avatar
  • 146
4 votes
Accepted

Where is mhtml mode defined? And why am I getting it by default when I open HTML files?

mhtml-mode is defined in mhtml-mode.el. You can find it using M-x find-function mhtml-mode. Other interesting commands for locating/finding libraries: With M-x locate-library RET mhtml-mode RET the ...
Alex's user avatar
  • 1,018
4 votes
Accepted

How to put inline quotes in an org file for html export

You can achieve your desired result with a macro like this (which should also work for latex, but without the url): #+MACRO: quote @@html:<q cite="$2">$1</q>@@@@latex:``$1''@@ And then ...
theldoria's user avatar
  • 1,825
4 votes

Live view an html document in emacs

Live preview of Markdown in Emacs is discussed in the terrific Guide to Markdown Mode for Emacs and also at the Emacs wiki. The markdown-preview-eww package will use Emacs' build-in eww browser to ...
dotancohen's user avatar
4 votes
Accepted

Setting variable for org-mode html export?

For variables that cannot be set through the #+OPTIONS keyword, the #+BIND keyword mechanism can be used. Adding #+BIND: org-html-link-org-files-as-html:nil to the top of your file would be ...
NickD's user avatar
  • 25.9k
4 votes
Accepted

How write begin_export html blocks in an inline fashion?

As described in the org manual, alongside the explanation of #+BEGIN_EXPORT html @@html:the quick <b>brown</b> fox@@
Tyler's user avatar
  • 21.4k

Only top scored, non community-wiki answers of a minimum length are eligible