Skip to content

Commit

Permalink
Update 1.2.0
Browse files Browse the repository at this point in the history
- Support _markdown.css alongside markdown files for styling
- Correct comparisons to use non-coercing equality
- Replace fixed-size icons with SVG
- Complete and correct license file
  • Loading branch information
KeithLRobertson committed Oct 3, 2017
1 parent 83a38c3 commit 4d1d7b6
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 99 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "lib/markdown-it-checkbox"]
path = lib/markdown-it-checkbox
url = https://github.com/mcecot/markdown-it-checkbox.git
[submodule "lib/highlightjs"]
path = lib/highlightjs
url = https://github.com/components/highlightjs.git
[submodule "lib/markdown-it"]
path = lib/markdown-it
url = https://github.com/markdown-it/markdown-it.git
[submodule "lib/markdown-it-checkbox"]
path = lib/markdown-it-checkbox
url = https://github.com/mcecot/markdown-it-checkbox.git
82 changes: 60 additions & 22 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ This Sofware is based on:

------------------------------------------------------------------------------

Original markdown-viewer: i.e. some of ext/content.js (https://github.com/Thiht/markdown-viewer)

Copyright (c) 2012-2013 Rousseau Thibaut

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

------------------------------------------------------------------------------

highlightjs (https://github.com/isagalaev/highlight.js)

Copyright (c) 2006, Ivan Sagalaev
Expand All @@ -39,8 +63,8 @@ modification, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of highlight.js nor the names of its contributors
may be used to endorse or promote products derived from this software
* Neither the name of highlight.js nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
Expand Down Expand Up @@ -109,35 +133,49 @@ THE SOFTWARE.

------------------------------------------------------------------------------

[Original code: i.e. some of ext/content.js]
markdown-mark (https://github.com/dcurtis/markdown-mark)

Copyright (c) 2012-2013 Rousseau Thibaut
DEDICATED TO THE PUBLIC DOMAIN BY DUSTIN CURTIS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The Markdown Mark has been dedicated to the public domain. It is protected by the Creative Commons CC0 Universal Public Domain Dedication license. You can read the entire license below or at http://creativecommons.org/publicdomain/zero/1.0/deed.en.

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
CC0 UNIVERSAL PUBLIC DOMAIN DEDICATION LICENSE

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.

For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following:
a. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
b. moral rights retained by the original author(s) and/or performer(s);
c. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;
rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below;
d. rights protecting the extraction, dissemination, use and reuse of data in a Work;
e. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
f. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.

------------------------------------------------------------------------------

[sss: css files]
SSS Simple Style Sheet (https://github.com/Thiht/sss)

The MIT License (MIT)

Copyright (c) 2016
Copyright (c) 2016 Thibaut Rousseau

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -157,4 +195,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

------------------------------------------------------------------------------
------------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Markdown (.md) file viewer [WebExtension](https://developer.mozilla.org/en-US/Ad
## Test
* (Firefox won't install the generated .zip unless it's signed by Mozilla; you can test from the staging folder.)
* Navigate to the staging folder and run `web-ext run`.
* Or install `staging/manifest.json` [temporarily in Firefox](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox).
* Or install `staging/manifest.json` [temporarily in Firefox](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox).
6 changes: 3 additions & 3 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
lib\sss\sss.print.css
) do @call :copyfile %%f staging\%%f

@browserify .\ext\content.js^
@call browserify .\ext\content.js^
-r .\lib\highlightjs\highlight.pack.min.js:highlight.js^
-r .\lib\markdown-it\dist\markdown-it.min.js:markdown-it^
-r .\lib\markdown-it-checkbox\dist\markdown-it-checkbox.min.js:markdown-it-checkbox^
-r .\lib\highlightjs\highlight.pack.min.js:highlight.js^
-o .\staging\ext\content.js

@web-ext build -s staging
@call web-ext build -s staging
@goto :EOF

:copyfile
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ do
done

browserify ./ext/content.js\
-r ./lib/highlightjs/highlight.pack.min.js:highlight.js\
-r ./lib/markdown-it/dist/markdown-it.min.js:markdown-it\
-r ./lib/markdown-it-checkbox/dist/markdown-it-checkbox.min.js:markdown-it-checkbox\
-r ./lib/highlightjs/highlight.pack.min.js:highlight.js\
-o ./staging/ext/content.js

web-ext build -s staging
Binary file removed ext/208x128.png
Binary file not shown.
Binary file removed ext/32x20.png
Binary file not shown.
Binary file removed ext/48x30.png
Binary file not shown.
Binary file removed ext/66x40.png
Binary file not shown.
2 changes: 1 addition & 1 deletion ext/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const markdownFileExtension = /\.m(arkdown|kdn?|d(o?wn)?)(\?.*)?(#.*)?$/i;

if (changeInfo.status == 'complete' && markdownFileExtension.test(tab.url)) {
if (changeInfo.status === 'complete' && markdownFileExtension.test(tab.url)) {

// Support loading additional scripts on demand by content script.
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
Expand Down
25 changes: 13 additions & 12 deletions ext/content.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
function addStylesheet(path, media) {
function addStylesheet(href, media) {
var style = document.createElement('link');
style.rel = 'stylesheet';
if (media) { style.setAttribute('media', media); }
style.type = 'text/css';
style.href = browser.extension.getURL(path);
style.href = href;
if (media) { style.setAttribute('media', media); }
document.head.appendChild(style);
}

function processMarkdown(textContent) {
// Parse the content Markdown => HTML

var hljs = require('highlight.js');

var md = require('markdown-it')({
html: true,
linkify: true,
Expand All @@ -26,7 +26,6 @@ function processMarkdown(textContent) {
try {
return hljs.highlightAuto(str).value;
} catch (__) {}

return ''; // use external default escaping
}
})
Expand All @@ -36,9 +35,11 @@ function processMarkdown(textContent) {
var html = md.render(textContent);

// Style the page and code highlights.
addStylesheet('lib/sss/sss.css');
addStylesheet('lib/sss/sss.print.css', 'print');
addStylesheet('lib/highlightjs/styles/default.css');
addStylesheet(browser.extension.getURL('lib/sss/sss.css'));
addStylesheet(browser.extension.getURL('lib/sss/sss.print.css'), 'print');
addStylesheet(browser.extension.getURL('lib/highlightjs/styles/default.css'));
// User-defined stylesheet.
addStylesheet('_markdown.css');

// This is considered a good practice for mobiles.
var viewport = document.createElement('meta');
Expand Down Expand Up @@ -90,12 +91,12 @@ function processMarkdown(textContent) {

// Execute only if .md is unprocessed text.
var body = document.body;
if (body.childNodes.length == 1 &&
body.children.length == 1 &&
body.children[0].nodeName.toUpperCase() == 'PRE')
if (body.childNodes.length === 1 &&
body.children.length === 1 &&
body.children[0].nodeName.toUpperCase() === 'PRE')
{
var textContent = body.textContent;
body.textContent = '';

processMarkdown(textContent);
}
}
1 change: 1 addition & 0 deletions ext/markdown-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 0 additions & 21 deletions lib/sss/LICENSE

This file was deleted.

14 changes: 6 additions & 8 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"manifest_version": 2,
"name": "markdown-viewer-webext",
"version": "1.1.0",
"name": "Markdown Viewer Webext",
"version": "1.2.0",
"homepage_url": "https://github.com/KeithLRobertson/markdown-viewer",
"description": "Displays markdown documents beautified.\n\nMarkdown is a lightweight markup language which uses plain text to describe formatting information, such as # Heading, 1. numbered list, *bold*, etc. This add-on identifies markdown documents by the extension in the URL (.md, .markdown, etc.). When you navigate to a markdown document, if the content is plain text, this add-on formats it into HTML (with headings, bold text, etc.) as described in the document and displays it directly in your browser.\n\nA markdown document can contain Unicode characters, but it must begin with a Byte Order Marker for those characters to display correctly.",
"description": "Displays markdown documents beautified in your browser.",

"permissions": [
"activeTab", "tabs", "<all_urls>"
],

"icons": {
"32": "ext/32x20.png",
"48": "ext/48x30.png",
"66": "ext/66x40.png",
"208": "ext/208x128.png"
"48": "ext/markdown-mark.svg",
"96": "ext/markdown-mark.svg"
},

"background": {
Expand Down
1 change: 1 addition & 0 deletions test/_markdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1 { font-weight: 700; color: #00a }
Loading

0 comments on commit 4d1d7b6

Please sign in to comment.