diff options
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/net/newst-backend.el | 32 | ||||
| -rw-r--r-- | lisp/xml.el | 19 |
3 files changed, 38 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index aaa1a4b861e..57d5b213bb9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2009-12-06 Ulf Jasper <ulf.jasper@web.de> | ||
| 2 | |||
| 3 | * xml.el (xml-substitute-numeric-entities): Moved | ||
| 4 | newsticker--decode-numeric-entities in newst-backend.el to | ||
| 5 | xml-substitute-numeric-entities in xml.el. (Bug#5008) | ||
| 6 | |||
| 7 | * net/newst-backend.el (newsticker--parse-generic-feed) | ||
| 8 | (newsticker--parse-generic-items) | ||
| 9 | (newsticker--decode-numeric-entities): Moved | ||
| 10 | newsticker--decode-numeric-entities in newst-backend.el to | ||
| 11 | xml-substitute-numeric-entities in xml.el. (Bug#5008) | ||
| 12 | |||
| 1 | 2009-12-06 Daniel Colascione <dan.colascione@gmail.com> | 13 | 2009-12-06 Daniel Colascione <dan.colascione@gmail.com> |
| 2 | 14 | ||
| 3 | * progmodes/js.el (js--js-not): Add null to the list of values. | 15 | * progmodes/js.el (js--js-not): Add null to the list of values. |
diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el index 24c4c89fb84..ae028516fb8 100644 --- a/lisp/net/newst-backend.el +++ b/lisp/net/newst-backend.el | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | ;; Filename: newst-backend.el | 7 | ;; Filename: newst-backend.el |
| 8 | ;; URL: http://www.nongnu.org/newsticker | 8 | ;; URL: http://www.nongnu.org/newsticker |
| 9 | ;; Keywords: News, RSS, Atom | 9 | ;; Keywords: News, RSS, Atom |
| 10 | ;; Time-stamp: "4. Dezember 2009, 20:08:17 (ulf)" | 10 | ;; Time-stamp: "5. Dezember 2009, 13:21:27 (ulf)" |
| 11 | 11 | ||
| 12 | ;; ====================================================================== | 12 | ;; ====================================================================== |
| 13 | 13 | ||
| @@ -1408,9 +1408,9 @@ description, link, and extra elements resp." | |||
| 1408 | (position 0) | 1408 | (position 0) |
| 1409 | (something-was-added nil)) | 1409 | (something-was-added nil)) |
| 1410 | ;; decode numeric entities | 1410 | ;; decode numeric entities |
| 1411 | (setq title (newsticker--decode-numeric-entities title)) | 1411 | (setq title (xml-substitute-numeric-entities title)) |
| 1412 | (setq desc (newsticker--decode-numeric-entities desc)) | 1412 | (setq desc (xml-substitute-numeric-entities desc)) |
| 1413 | (setq link (newsticker--decode-numeric-entities link)) | 1413 | (setq link (xml-substitute-numeric-entities link)) |
| 1414 | ;; remove whitespace from title, desc, and link | 1414 | ;; remove whitespace from title, desc, and link |
| 1415 | (setq title (newsticker--remove-whitespace title)) | 1415 | (setq title (newsticker--remove-whitespace title)) |
| 1416 | (setq desc (newsticker--remove-whitespace desc)) | 1416 | (setq desc (newsticker--remove-whitespace desc)) |
| @@ -1462,10 +1462,10 @@ argument, which is one of the items in ITEMLIST." | |||
| 1462 | (when (or (> (length title) 0) | 1462 | (when (or (> (length title) 0) |
| 1463 | (> (length desc) 0)) | 1463 | (> (length desc) 0)) |
| 1464 | ;; decode numeric entities | 1464 | ;; decode numeric entities |
| 1465 | (setq title (newsticker--decode-numeric-entities title)) | 1465 | (setq title (xml-substitute-numeric-entities title)) |
| 1466 | (when desc | 1466 | (when desc |
| 1467 | (setq desc (newsticker--decode-numeric-entities desc))) | 1467 | (setq desc (xml-substitute-numeric-entities desc))) |
| 1468 | (setq link (newsticker--decode-numeric-entities link)) | 1468 | (setq link (xml-substitute-numeric-entities link)) |
| 1469 | ;; remove whitespace from title, desc, and link | 1469 | ;; remove whitespace from title, desc, and link |
| 1470 | (setq title (newsticker--remove-whitespace title)) | 1470 | (setq title (newsticker--remove-whitespace title)) |
| 1471 | (setq desc (newsticker--remove-whitespace desc)) | 1471 | (setq desc (newsticker--remove-whitespace desc)) |
| @@ -1517,24 +1517,6 @@ argument, which is one of the items in ITEMLIST." | |||
| 1517 | ;; ====================================================================== | 1517 | ;; ====================================================================== |
| 1518 | ;;; Misc | 1518 | ;;; Misc |
| 1519 | ;; ====================================================================== | 1519 | ;; ====================================================================== |
| 1520 | (defun newsticker--decode-numeric-entities (string) | ||
| 1521 | "Decode SGML numeric entities by their respective utf characters. | ||
| 1522 | This function replaces numeric entities in the input STRING and | ||
| 1523 | returns the modified string. For example \"*\" gets replaced | ||
| 1524 | by \"*\"." | ||
| 1525 | (if (and string (stringp string)) | ||
| 1526 | (let ((start 0)) | ||
| 1527 | (while (string-match "&#\\([0-9]+\\);" string start) | ||
| 1528 | (condition-case nil | ||
| 1529 | (setq string (replace-match | ||
| 1530 | (string (read (substring string | ||
| 1531 | (match-beginning 1) | ||
| 1532 | (match-end 1)))) | ||
| 1533 | nil nil string)) | ||
| 1534 | (error nil)) | ||
| 1535 | (setq start (1+ (match-beginning 0)))) | ||
| 1536 | string) | ||
| 1537 | nil)) | ||
| 1538 | 1520 | ||
| 1539 | (defun newsticker--remove-whitespace (string) | 1521 | (defun newsticker--remove-whitespace (string) |
| 1540 | "Remove leading and trailing whitespace from STRING." | 1522 | "Remove leading and trailing whitespace from STRING." |
diff --git a/lisp/xml.el b/lisp/xml.el index e86232d5718..ac96286fdec 100644 --- a/lisp/xml.el +++ b/lisp/xml.el | |||
| @@ -823,6 +823,25 @@ This follows the rule [28] in the XML specifications." | |||
| 823 | "") | 823 | "") |
| 824 | (substring string point)))))) | 824 | (substring string point)))))) |
| 825 | 825 | ||
| 826 | (defun xml-substitute-numeric-entities (string) | ||
| 827 | "Substitute SGML numeric entities by their respective utf characters. | ||
| 828 | This function replaces numeric entities in the input STRING and | ||
| 829 | returns the modified string. For example \"*\" gets replaced | ||
| 830 | by \"*\"." | ||
| 831 | (if (and string (stringp string)) | ||
| 832 | (let ((start 0)) | ||
| 833 | (while (string-match "&#\\([0-9]+\\);" string start) | ||
| 834 | (condition-case nil | ||
| 835 | (setq string (replace-match | ||
| 836 | (string (read (substring string | ||
| 837 | (match-beginning 1) | ||
| 838 | (match-end 1)))) | ||
| 839 | nil nil string)) | ||
| 840 | (error nil)) | ||
| 841 | (setq start (1+ (match-beginning 0)))) | ||
| 842 | string) | ||
| 843 | nil)) | ||
| 844 | |||
| 826 | ;;******************************************************************* | 845 | ;;******************************************************************* |
| 827 | ;;** | 846 | ;;** |
| 828 | ;;** Printing a tree. | 847 | ;;** Printing a tree. |