From: Jeremy Friesen <jeremy.n.friesen@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: Adding more tags for SHR
Date: Thu, 26 Aug 2021 21:13:16 -0400 [thread overview]
Message-ID: <CALSSkZsXuxP6UYz3p675r5=dznWVBZsYp30Xn9wZNUfMMQ+bHA@mail.gmail.com> (raw)
In-Reply-To: <87fsuvu4eg.fsf@gnus.org>
[-- Attachment #1.1: Type: text/plain, Size: 2467 bytes --]
Lars, thank you for the feedback.
I've also sent my information to assign@gnu.org.
I went a slightly different route on the q-tag by having an "around"
defcustom using a cons. I also opted to default to a straight quotes
instead of "curly quotes". I'm uncertain how I can set a :type that is
either a 'string or 'nil. (Though I'm very willing to keep working on this)
Attached is iteration 0002 of the changes.
On Thu, Aug 26, 2021 at 8:18 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Jeremy Friesen <jeremy.n.friesen@gmail.com> writes:
>
> > Attached is a patch for more rendering options for SHR.
>
> Thanks; looks great!
>
> A couple very minor comments:
>
> > +(defcustom shr-before-q-tag "“"
> > + "Before quote used for q-tag.
>
> Perhaps it'd be best to default this to nil and then do something along
> the lines of
>
> (shr-insert (or shr-before-q-tag
> (if (char-displayable-p ?“) ?“ ?\")))
>
> in -tag-q to ensure that the default is displayable everywhere.
>
> > +(defun shr-tag-time (dom)
> > + (when-let* ((datetime (or
>
> Misindented?
>
> This change is larger than what we can apply without getting a copyright
> assignment for the FSF.
>
> https://www.gnu.org/licenses/why-assign.en.html
>
> Are you willing to sign such paperwork? If so, here's the paperwork to
> get started.
>
> Please email the following information to assign@gnu.org, and we
> will send you the assignment form for your past and future changes.
>
> Please use your full legal name (in ASCII characters) as the subject
> line of the message.
> ----------------------------------------------------------------------
> REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
>
> [What is the name of the program or package you're contributing to?]
> Emacs
>
> [Did you copy any files or text written by someone else in these changes?
> Even if that material is free software, we need to know about it.]
>
> [Do you have an employer who might have a basis to claim to own
> your changes? Do you attend a school which might make such a claim?]
>
> [For the copyright registration, what country are you a citizen of?]
>
> [What year were you born?]
>
> [Please write your email address here.]
>
> [Please write your postal address here.]
>
> [Which files have you changed so far, and which new files have you written
> so far?]
>
>
--
Jeremy Friesen
takeonrules.com
[-- Attachment #1.2: Type: text/html, Size: 3477 bytes --]
[-- Attachment #2: 0002-Add-new-shr-faces-and-rendering-functions.patch --]
[-- Type: application/octet-stream, Size: 3453 bytes --]
From f73824a175ef6067d3bc5ee5930b552bbf25da25 Mon Sep 17 00:00:00 2001
From: Jeremy Friesen <jeremy.n.friesen@gmail.com>
Date: Thu, 26 Aug 2021 17:05:52 -0400
Subject: [PATCH] Add new shr faces and rendering functions
* lisp/net/shr.el (shr-tag-cite): Add <CITE> tag
* lisp/net/shr.el (shr-tag-dfn): Add <DFN> tag
* lisp/net/shr.el (shr-tag-small): Add <SMALL> tag
* lisp/net/shr.el (shr-tag-time): Add <TIME> tag
* lisp/net/shr.el (shr-tag-q): Add <Q> tag
* lisp/net/shr.el (shr-around-q-tag): New defcustom
* lisp/net/shr.el (shr-time): New defface
* lisp/net/shr.el (shr-small): New defface
---
lisp/net/shr.el | 45 ++++++++++++++++++++++++++++++
test/lisp/net/shr-resources/q.html | 1 +
test/lisp/net/shr-resources/q.txt | 1 +
3 files changed, 47 insertions(+)
create mode 100644 test/lisp/net/shr-resources/q.html
create mode 100644 test/lisp/net/shr-resources/q.txt
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 85d81b6bbc..dbb45c3ff1 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -128,6 +128,14 @@ Alternative suggestions are:
:version "24.4"
:type 'string)
+(defcustom shr-around-q-tag '("\"" . "\"")
+ "The before and after quotes for a Q-tag.
+- `car' is inserted before the Q-tag
+- `cdr' is inserted after the Q-tag.
+Alternative suggestions are: - '(\"“\" . \"”\")"
+ :version "28.1"
+ :type (cons 'string 'string))
+
(defcustom shr-cookie-policy 'same-origin
"When to use cookies when fetching dependent data like images.
If t, always use cookies. If nil, never use cookies. If
@@ -183,6 +191,16 @@ temporarily blinks with this face."
"Face for <abbr> elements."
:version "27.1")
+(defface shr-time
+ '((t :inherit underline :underline (:style wave)))
+ "Face for <time> elements."
+ :version "28.1")
+
+(defface shr-small
+ '((t :height 0.8))
+ "Face for <small> elements."
+ :version "28.1")
+
(defface shr-h1
'((t :height 1.3 :weight bold))
"Face for <h1> elements."
@@ -1498,9 +1516,36 @@ ones, in case fg and bg are nil."
(defun shr-tag-em (dom)
(shr-fontize-dom dom 'italic))
+(defun shr-tag-cite (dom)
+ (shr-fontize-dom dom 'italic))
+
+(defun shr-tag-dfn (dom)
+ (shr-fontize-dom dom 'italic))
+
(defun shr-tag-strong (dom)
(shr-fontize-dom dom 'bold))
+(defun shr-tag-small (dom)
+ (shr-fontize-dom dom (if shr-use-fonts 'shr-small)))
+
+(defun shr-tag-q (dom)
+ (shr-insert (car shr-around-q-tag))
+ (shr-generic dom)
+ (shr-insert (cdr shr-around-q-tag)))
+
+(defun shr-tag-time (dom)
+ (when-let* ((datetime (or
+ (dom-attr dom 'title)
+ (dom-attr dom 'datetime)))
+ (start (point)))
+ (shr-generic dom)
+ (shr-add-font start (point) 'shr-time)
+ (add-text-properties
+ start (point)
+ (list
+ 'help-echo datetime
+ 'mouse-face 'highlight))))
+
(defun shr-tag-u (dom)
(shr-fontize-dom dom 'underline))
diff --git a/test/lisp/net/shr-resources/q.html b/test/lisp/net/shr-resources/q.html
new file mode 100644
index 0000000000..e60e8e39a6
--- /dev/null
+++ b/test/lisp/net/shr-resources/q.html
@@ -0,0 +1 @@
+<q>Hello World</q>
\ No newline at end of file
diff --git a/test/lisp/net/shr-resources/q.txt b/test/lisp/net/shr-resources/q.txt
new file mode 100644
index 0000000000..be5d95a193
--- /dev/null
+++ b/test/lisp/net/shr-resources/q.txt
@@ -0,0 +1 @@
+"Hello World"
\ No newline at end of file
--
2.31.1
next prev parent reply other threads:[~2021-08-27 1:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 21:19 Adding more tags for SHR Jeremy Friesen
2021-08-27 0:17 ` Lars Ingebrigtsen
2021-08-27 1:13 ` Jeremy Friesen [this message]
2021-08-27 1:21 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALSSkZsXuxP6UYz3p675r5=dznWVBZsYp30Xn9wZNUfMMQ+bHA@mail.gmail.com' \
--to=jeremy.n.friesen@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.