GithubHelp home page GithubHelp logo

emacs-htmlize's People

Contributors

hniksic avatar jabranham avatar jmdeldin avatar stig avatar syohex avatar tarsius avatar tpapp avatar xuchunyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emacs-htmlize's Issues

No support for the face `:extend` attribute.

This comparison shows emacs 29 (current git) with ediff that uses ediff-odd-diff-A face which defaults to:

Face: ediff-odd-diff-A (sample) (customize this face)

Documentation:
Face for highlighting odd-numbered non-current differences in buffer A.

Defined in ‘ediff-init.el’.


           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: unspecified
            Slant: unspecified
       Foreground: unspecified
DistantForeground: unspecified
       Background: #3e3e5e
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
           Extend: t
          Inherit: unspecified

Screenshot of emacs/html compared.
extend_unsupported

Package cl is deprecated

(require 'loadhist)
(file-dependents (feature-file 'cl))

Shows that htmlize/htmlize.elc depends on cl which is deprecated in emacs 27.

EDIT: I made I typo on (feature-file 'htmlize), it was cl

Error running 'htmlize-region'

Hi, I'm seeing this exact same issue as #6 and am not able to resolve it by restarting emacs, or any other means. I am able to call html-buffer just fine, however htmlize-region always fails with that exact same error.

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p (nil . 100))
<((nil . 100) 99)
#[514 "\300	�!	�!\"\207" [< cl-key] 6 "\n\n(fn CL-X CL-Y)"](#<overlay from 50652 to 51034 in BrandController.scala> #<overlay from 50652 to 51034 in BrandController.scala>)
sort((#<overlay from 50652 to 51034 in BrandController.scala>) #[514 "\300	�!	�!\"\207" [< cl-key] 6 "\n\n(fn CL-X CL-Y)"])
cl-sort((#<overlay from 50652 to 51034 in BrandController.scala>) < :key #[257 "\300�\301\"\206\302\207" [overlay-get priority 0] 4 "\n\n(fn O)"]))
  stable-sort((#<overlay from 50652 to 51034 in BrandController.scala>) < :key #[257 "\300�\301\"\206�\302\207" [overlay-get priority 0] 4 "\n\n(fn O)"])
  htmlize-faces-at-point()
  htmlize-buffer-1()
  htmlize-region(50652 51034)
  funcall-interactively(htmlize-region 50652 51034)
  call-interactively(htmlize-region record nil)
  command-execute(htmlize-region record)
  #[257 "\304\305!\203\f

I've only just used htmlize for the first time, and simply calling htmlize-region interactively is failing for me. I tried it on files of different types and sizes and it continues to fail.

I've narrowed this problem down the following lines: https://github.com/hniksic/emacs-htmlize/blob/master/htmlize.el#L1383-L1389

If I comment them out, then this function runs perfectly.

Thanks!

Request to release version 1.58

@hniksic , @yantar92 , @tarsius :

This issue affects both melpa-stable as well as nongnu ELPA. The latest
version available on both is 1.56, from three years ago. Since then, a fix for
issue #49 has been merged which fixes an issue when exporting SVG images.

As noted in #36 , while melpa-stable uses tagged commits, nongnu ELPA uses
commits that increment the version tag in the package header to identify new
(stable) versions.

Could version 1.57 be released and made available (preferably on both, but
even if only on melpa-stable it would be okay)?

Submitting copyright to FSF, and GPLv3?

Hello,

Recently this discussion came up on Emacs help and Org mode mailing lists: https://lists.gnu.org/r/emacs-orgmode/2018-09/msg00110.html

Currently Org mode suggests users to download your awesome htmlize package from GitHub so that ox-html can export proper syntax highlighted code blocks.

While I don't mind that (and I already use htmlize), there are some people who wouldn't prefer that?

Do you have an objection to assigning your copyright to FSF? With that in place, this package can be a part of Emacs/Org mode, and resolve the issue discussed in that mailing list thread.

If interested, please email [email protected] for instructions with this assignment process (I've done it, and it's very easy).

All colouring lost.

If I run htmlize-{buffer,file} on any of my files, the result has no syntax highlighting.

Additionally, if I turn on debug-on-error I find the following

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("[\11\n]" nil 0)
  htmlize-untabify-string(nil 0)
  htmlize-extract-text(1 2 nil)
  ...
  htmlize-buffer-1()
  htmlize-region(1 1817)
  org-html-htmlize-region-for-paste(1 1817)

Here's an example output: colophon.zip

I use Emacs27.1 with Doom, which uses the latest version of Htmlize, and does not appear to modify the settings/behaviour.

Duplicated images if buffer with tabs in images are untabified

The following lisp-code creates a buffer *test* with an embedded svg image data.

If htmlize-untabify is t, then the image appears as replacement for every tab in the HTML file generated with htmlize-buffer – three times overall.

This is because htmlize-untabify-string accidently puts the display property
with the image on the corresponding table entry in htmlize-tab-spaces.

(with-current-buffer (get-buffer-create "*test*")
  (let (b e)
    (erase-buffer)
    (insert "\t  Text before\n\t")
    (setq b (point))
    (insert (propertize "bold\n" 'face 'bold)
	    (propertize "\titalic\n" 'face 'italic))
    (setq e (point))
    (insert "\n\tText after")
    (let ((ol (make-overlay b e)))
      (overlay-put
       ol
       'display
       (create-image
	"<svg height=\"140\" width=\"500\" xmlns=\"http://www.w3.org/2000/svg\">
  <ellipse rx=\"100\" ry=\"50\" cx=\"120\" cy=\"80\"
  style=\"fill:yellow;stroke:green;stroke-width:3\" />
</svg>"
	'svg
	t)))))

Error on htmlizing region

Hi, I was wondering if you could figure out why I might be getting the following error when I call htmlize-region: Wrong type argument: number-or-marker-p, (nil . 100)

I toggled debug-on-error and I got the following backtrace which shows that the parameters to the sort function are wrong but I couldn't really see how to fix this wrong key that is being fed to the sort function

debug(error (wrong-type-argument number-or-marker-p (nil . 100)))
  <((nil . 100) 110)
  #[514 "\300	�!	�!\"\207" [< cl-key] 6 "\n\n(fn CL-X CL-Y)"](#<overlay from 1 to 1087 in benchmark.py> #<overlay from 1 to 7 in benchmark.py>)
  sort((#<overlay from 1 to 7 in benchmark.py>) #[514 "\300	�!	�!\"\207" [< cl-key] 6 "\n\n(fn CL-X CL-Y)"])
  cl-sort((#<overlay from 1 to 7 in benchmark.py>) < :key #[257 "\300�\301\"\206��\302\207" [overlay-get priority 0] 4 "\n\n(fn O)"])
  apply(cl-sort (#<overlay from 1 to 7 in benchmark.py>) < (:key #[257 "\300�\301\"\206��\302\207" [overlay-get priority 0] 4 "\n\n(fn O)"]))
  stable-sort((#<overlay from 1 to 7 in benchmark.py>) < :key #[257 "\300�\301\"\206��\302\207" [overlay-get priority 0] 4 "\n\n(fn O)"])
  htmlize-faces-at-point()
  htmlize-buffer-1()
  htmlize-region(1 1087)
  funcall-interactively(htmlize-region 1 1087)
  call-interactively(htmlize-region record nil)

Error (void-variable overlay)

Hi,

I have a problem with htmlize. If I open I simple text file, and try to run htmlize on it, I have the following error:

------->8-------------8<--------
Debugger entered--Lisp error: (void-variable overlays)
htmlize-sorted-overlays-at(1)
htmlize-faces-at-point()
htmlize-buffer-1()
htmlize-file("~/tmp/prova-org/example.txt")
call-interactively(htmlize-file record nil)
command-execute(htmlize-file record)
execute-extended-command(nil "htmlize-file")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
------->8-------------8<--------

I have emacs 24.5.1, and I use the htmlize package from downloaded from the git. Here is my .emacs:

------->8-------------8<--------
(add-to-list 'load-path "/elisp/")
(add-to-list 'load-path "
/elisp/org-mode/lisp")
(add-to-list 'load-path "~/elisp/emacs-htmlize" t)

(require 'org)
(org-babel-load-file
(expand-file-name "minimal_init.org"
user-emacs-directory))
------->8-------------8<--------

and here is my minimal_init.org file

------->8-------------8<--------
#+BEGIN_SRC emacs-lisp
(setq-default)
(setq inhibit-splash-screen t)
#+END_SRC
------->8-------------8<--------

I run into this problem a few days ago when I tried to export a org-mode file containing src code blocks to html. It was working until a few weeks ago, then suddenly this error. For some reason, it seems I am the only one having this problem; nobody else noticed it, or can reproduce it in the org mailing list.

Can you help me solving this issue?

Best regards,

Giuseppe Lipari

Splicing in overlays breaks for literate-calc-mode

This was noticed by a user (sulami/literate-calc-mode.el#17).

I have not done any extensive research, but I can provide a traceback & a minimal example.

#+begin_src literate-calc
Pi = 3.14159
#+end_src
Debugger entered--Lisp error: (args-out-of-range "Pi " 0 12)
  substring("Pi " 0 12)
  htmlize-add-before-after-strings(1 4 "Pi ")
  htmlize-get-text-with-display(1 4)
  htmlize-buffer-substring-no-invisible(1 4)
  htmlize-extract-text(1 4 nil)
  htmlize-buffer-1()
  htmlize-region(1 13)
  org-html-htmlize-region-for-paste(1 13)
  org-html-fontify-code("Pi = 3.14159" "literate-calc")
  org-html-do-format-code("Pi = 3.14159" "literate-calc" nil t nil nil)
  [ more frames omitted ]

This is where the traceback leads me.

Warning about font-lock-fontify-buffer with Emacs 25.3

With Emacs 25.3, byte-compiling htmlize.el triggers a warning:

In htmlize-file:
htmlize.el:1893:17:Warning: `font-lock-fontify-buffer' is for interactive use
    only; use `font-lock-ensure' or `font-lock-flush' instead.

The following patch solves this (while still fontifying the output :-)):

--- /dev/fd/63  2018-01-07 01:24:02.790734877 +0000
+++ emacs-htmlize-release-1.51/htmlize.el       2018-01-07 00:42:57.278556882 +0000
@@ -1889,11 +1889,7 @@
       (let ((buffer-file-name file))
        ;; Set the major mode for the sake of font-lock.
        (normal-mode)
-       (font-lock-mode 1)
-       (unless font-lock-mode
-         ;; In GNU Emacs (font-lock-mode 1) doesn't force font-lock,
-         ;; contrary to the documentation.  This seems to work.
-         (font-lock-fontify-buffer))
+       (font-lock-ensure)
        ;; htmlize the buffer and save the HTML.
        (with-current-buffer (htmlize-buffer-1)
          (unwind-protect

As I don't know the best way to preserve compatibility with Emacs 21/21, I won't submit this as a pull request (BTW, htmlize.el "aims for compatibility with Emacsen version 21 and later", while README.md "aims for compatibility with Emacsen version 22 and later").

tag releases

Would you mind tagging releases, so MELPA Stable can pick them up? Thanks!

Faces not recognized

I'm using color-identifiers-mode with some custom setup to change most of the highlighting from the code. IOW the code highlight I see is drastically different from just the theme in use.

However htmlize-buffer makes html which instead looks like the theme in use.

Steps to reproduce:

  1. Open emacs -Q (it will open a scratch buffer with a comment).
  2. Use load-file to load htmlize.el
  3. Execute (face-remap-add-relative 'font-lock-comment-face '((:weight bold)))
  4. Execute htmlize-buffer

Expected result: resulting html should have a bold text.
Actual result: bold keyword is ignored.

SVG inline image broken

The following lisp-code creates a buffer *test* with an embedded svg image data.

The image is broken in the HTML file generated by htmlize-buffer in buffer *test*.

The reason is that the data is exported with Mime type svg instead of svg+xml.

(with-current-buffer (get-buffer-create "*test*")
  (let (b e)
    (erase-buffer)
    (insert "\t  Text before\n\t")
    (setq b (point))
    (insert (propertize "bold\n" 'face 'bold)
	    (propertize "\t  italic\n" 'face 'italic))
    (setq e (point))
    (insert "\n\tText after")
    (let ((ol (make-overlay b e)))
      (overlay-put
       ol
       'display
       (create-image
	"<svg height=\"140\" width=\"500\" xmlns=\"http://www.w3.org/2000/svg\">
<ellipse rx=\"100\" ry=\"50\" cx=\"120\" cy=\"80\"
style=\"fill:yellow;stroke:green;stroke-width:3\" />
</svg>"
	'svg
	t)))))

not convert tab to space in pre

is it possible to not convert tab to spaces inside pre tag?

in golang, its a community convention to use tabs, enforced by the bundled tool gofmt.
(and i think tabs are critical in makefile.)

I write tutorials. So my primary use of htmlize is to convert programing language source code to a htmlized form. With golang, this maybe be a minor problem. thanks.

Exclamation character in exported html

Hi,

I use org-re-reveal which uses htmlize.el to render the orgmode src blocks.

It works well except that an exclamation character "!" begins every line.

When looking into the html file, there is indeed an exclamation point.

I wonder if it is on purpose of it can be removed ?

Regards

Background color is not handled?

Hi

I'm using this htmlize with highlight2clipboard to copy a region to a clipboard in Mac OSX and it is very useful to present to mail or some other purpose.

However, it doesn't look that htmlize converts a region with the background color.

Is there an option or workaround for it?

Mentioning NonGNU ELPA

Hey, this is just to let you know that htmlize was added to the NonGNU ELPA package repository: https://elpa.nongnu.org/nongnu/htmlize.html

This shouldn't affect packaging, the main difference is that while MELPA uses tagged commits to identify new (stable) versions, NonGNU ELPA uses those commits that increment the version tag in the package header.

As the repository will be active by default from Emacs 28 onwards, you might be interested in adding a note that it can be installed without any further configuration.

Invalid face reference: t

I have code that execute lot of

(hlt-highlight-region start-pos end-pos '((t (:background "green")))))

and I got lot of errors Invalid face reference: t.

Org bundles an outdated version of htmlize

Org bundles an old version of htmlize.el, which identifies itself as 1.43. The version in this repository is 1.51.

  • @bzg as with some other libraries you have already removed, I think this one should be removed too.
  • org-agenda.el, ox-org.el, and ox-html.el require htmlize. It would probably be a good idea to check whether those libraries are compatible with 1.51.
  • @hniksic Assuming that you are an Org user, then I would like to encourage you to do that.

Thanks everyone!

Gnus faces

Sorry if I'm asking stupid questions here, I just like to understand the problem, and would understand if there would not be a solution.

I tried to htmlize a Gnus summary buffer. This is a list of mails in a folder. But htmlizing did not preserve styling. And after running htmlize, all styling was removed from the region or buffer.

So I started investigation, and describe-face didn't learn me much, cause it didn't automatically pick up the face where point was on.

So I did describe-char and this is what it gave me:

             position: 2880 of 13413 (21%), column: 70
            character: i (displayed as i) (codepoint 105, #o151, #x69)
              charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x69
               script: latin
               syntax: w 	which means: word
             category: .:Base, L:Left-to-right (strong), a:ASCII, l:Latin, r:Roman
             to input: type "C-x 8 RET 69" or "C-x 8 RET LATIN SMALL LETTER I"
          buffer code: #x69
            file code: #x69 (encoded by coding system utf-8)
              display: by this font (glyph code)
    ftcr:-CTDB-FuraCode Nerd Font Mono-normal-normal-normal-*-32-*-*-*-*-0-iso10646-1 (#x4B)

Character code properties: customize what to show
  name: LATIN SMALL LETTER I
  general-category: Ll (Letter, Lowercase)
  decomposition: (105) ('i')

There are text properties here:
  face                 (org-agenda-restriction-lock gnus-summary-normal-unread)
  gnus-face            t
  gnus-number          31997
  mouse-face           highlight

[back]

Wrong number of arguments error

I downloaded the code from:
https://github.com/hniksic/emacs-htmlize
master branch commit dd27bc3

I'm running:
GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.30) of 2018-11-02 on x86-01.bsys.centos.org

When I try to foramt a buffer with M-x htmlize-buffer I get the error:
nreverse: Wrong number of arguments: overlays-at, 2

Can you help me? Thanks!

htmlize mirror

In issue #23 org mode developers suggested having an official mirror for htmlize, and set one up. This issue is for making this mirror a documented mirror of htmlize source.

How to stop exporting?

I have lot of errors on big file and keep showing then in message buffer and M-g doesn't do anything. How can I stop processing?

put style in <pre> for inline-css

When htmlize-region-for-paste is used, the background color of the buffer is not used, which can lead to weird-looking outputs (eg with whitespace-mode). Please have inline-css put style in the <pre> tag, like for <body>.

wrong theme colors when emacs as daemon

Run emacs as emacs --daemon and emacsclient -c
choose a theme (example modus-vivendi) then htmlize a buffer

it was htmlized with modus-vivendi theme colors

now close the emacsclient window C-x C-c
then htmlize a buffer without any emacsclient window running (use functions running in emacs daemon)

now it was htmlized without theme colors

it is a problem if you're running emacs as a server

Elements of python-mode and highlight-indentation-mode get converted based on theme resulting in ugly colour styles

I noticed when exporting org-mode buffers to html that some characters got rendered in an undesired way:

  • Variables and Numbers in Python blocks: This issue on StackOverflow has a good screenshot showing the problem and also found the culprits: the variables py-number-face and py-variable-name-face from python-mode.el, which get an own <span> container when htmlized, and from me trying to tinker around I found that the background colour for this container is taken from the current Emacs theme's background colour of the respective characters.
  • These highlights - I think they come from highlight-indentation.el @antonj (see here). I have not tracked down the variable which is picked up here yet, but I examined it with some browser developer tools and it looks exactly like the issue above - these characters get a <span> container and the background colour of the Emacs theme. I made a screenshot:

Screenshot_20200512_210016

As described in the SO issue regarding the python-mode.el variables, there is a workaround in setting them to nil like this:

(setq py-number-face nil)
(setq py-variable-name-face nil)

But I think this is a quite dirty fix. Also, I could not yet fix the highlight-indentation problem (deactivating the minor mode didn't help).

Version information:
  • Emacs: 26.3
  • org: 9.3.6
  • htmlize: release/1.55-2-g86f22f2
  • python-mode: 6.2.3-284-g9c33629
  • highlight-indentation: v0.7.0-16-gd03803f

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.