-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow turning off center alignment of tables #175
Comments
On 2021-03-12 05:35, 積丹尼 Dan Jacobson wrote:
(Even if we own a wide monitor, we don't always want text pushed so far
to the right.)
Just a wee slightly off-topic: If you want to operate within the emacs
front-end for w3m, your request is easily handled by writing a
'filter' function, and adding an entry for it in emacs variable
`w3m-filter-configuration'.
Here's some sample code, possibly more complex than you need:
#+BEGIN_SRC emacs-lisp
(defun w3m-filter--left-align-tables (url)
"Left align all tables"
(goto-char (point-min))
(let (start bound)
(while (re-search-forward "<t[^>]+>" nil t)
(setq start (match-beginning 0)
bound (match-end 0))
(while (re-search-forward "align=\\(center\\)" bound t)
(replace-match "left" nil nil nil 1)
(setq bound (- bound 2)))
(goto-char start)
(while (re-search-forward "align=\\(right\\)" bound t)
(replace-match "left" nil nil nil 1)
(setq bound (- bound 1)))
(goto-char (1+ bound)))))
(add-to-list 'w3m-filter-configuration
'(t "left-align all tables"
".*"
w3m-filter--left-align-tables))
#+END_SRC
And here's a sample test html file:
#+BEGIN_SRC html
<html>
<body>
<h1> hello</h1>
<table width=100% align=center>
<tr align=right>
<td>cell 1: align=right <= should not be altered</td>
<td align=center align=right align=center> cell 2</td>
</tr>
</table>
<p align=center>This paragraph should be aligned center, ie. align=center
</p>
</body>
</html>
#+END_SRC
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
OK, but I get error: (void-variable w3m-filter-configuration), so I had to comment it out on |
On 2021-03-14 08:14, 積丹尼 Dan Jacobson wrote:
OK, but add-to-list 'w3m-filter-configuration gives an error there at
the bottom of
[1]https://www.jidanni.org/comp/configuration/.gnus.el
so I had to comment it out.
And it worked? If an entry isn't added to that list, there's no way for
emacs-w3m to know that the filter function exists or when to apply it!
What error did you receive?
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
@Boruch-Baum I see. I needed to wrap it in |
On 2021-03-18 16:30, 積丹尼 Dan Jacobson wrote:
***@***.*** I see. I needed to wrap it in
eval-after-load "w3m"
Yes, that is one solution. Emacs being emacs, there are alternatives: 1)
emacs-w3m has its own init file (see documentation for variable
`w3m-init-file'); 2) There's a package called `use-package' that seems
to have become very popular for this kind of thing.
OK. but wait, there is even tougher centering that needs to be
conquered, like in
[2]o.htm.gz
I'm unlikely to be the one to get to deal with that, at least any time
soon (Erev Shabbos is a wind-down and prepare period for me, next week is
likely to be dominated by the usual the pre-Pesach hysteria, the
week after is Pesach itself of course).
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
OK I finally figured it out, as I put in my
https://www.jidanni.org/comp/configuration/.emacs :
(require 'w3m-filter)
(defun w3m-filter-jidanni-zap-align-center (url)
"Move stuff back from center"
(w3m-filter-replace-regexp url "align=\"center\"" "" (point-min))
(w3m-filter-replace-regexp url "</?center>" "" (point-min)))
(add-to-list
'w3m-filter-configuration
'(t "Attempt to shrink tables by jidanni"
"" w3m-filter-jidanni-zap-align-center))
(setq mm-text-html-renderer 'w3m); not powerful enough... need:
(setq mm-text-html-renderer-alist
'((w3m . mm-shr) ; <--the culprit
(w3m . mm-inline-text-html-render-with-w3m)
(w3m . mm-inline-text-html-render-with-w3m-standalone)
(w3m . gnus-article-html)))
|
On 2021-04-08 15:21, 積丹尼 Dan Jacobson wrote:
OK I finally figured it out
...
Good to hear.
(setq mm-text-html-renderer 'w3m); not powerful enough... need:
...
'((w3m . mm-shr) ; <--the culprit
Every few years, I let myself get suckered into attempting to use GNUS,
and its learning curve and complexity never fail to astound me for
something that should be so simple. And the documentation ... phew ...
just take a look at the docstring for 'mm-shr' and the commentary at the
top of its lisp file ...
If you every get an itch to try an alternative, take a look at
'newsboat' (formerly 'newsbeuter'). It's trivial to start using; it's
easy to configure; it plays nicely with external programs (eg. w3m,
emacs, emacs-w3m); it has a zillion features, and; it's well documented.
If you do, and want some setup tips and macros to start you off, let me
know (off-line).
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
New option disable_center is now available. e.g. It will be included in Debian bullseye+1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lynx has
But for w3m we need to do
(Even if we own a wide monitor, we don't always want text pushed so far
to the right.)
The text was updated successfully, but these errors were encountered: