Browse Source

rename css file and refactor comments

Robert McGuinness 8 years ago
parent
commit
9b3cea821d
2 changed files with 11 additions and 12 deletions
  1. 11 12
      index.js
  2. 0 0
      prism-ebook.css

+ 11 - 12
index.js

@@ -42,10 +42,10 @@ module.exports = {
   book: getAssets,
   ebook: function() {
 
-    // Adding prism-pdf.css to the CSS collection forces Gitbook  to add a reference to it in the html
-    // markup that is converted into a PDF.
+    // Adding prism-ebook.css to the CSS collection forces Gitbook
+    // reference to it in the html markup that is converted into a PDF.
     var assets = getAssets.call(this);
-    assets.css.push('prism-pdf.css');
+    assets.css.push('prism-ebook.css');
     return assets;
 
   },
@@ -90,30 +90,29 @@ module.exports = {
   },
   hooks: {
 
-    // Copy prism-pdf.css into the temporary directory that Gitbook uses for inlining
-    // styles from this plugin.  This is done manually because prism-pdf.css lives outside
-    // the asset folder referenced above in getAssets().
+    // Manually copy prism-ebook.css into the temporary directory that Gitbook uses for inlining
+    // styles from this plugin. The getAssets() (above) function can't be leveraged because
+    // ebook-prism.css lives outside the folder referenced by this plugin's config.
     //
-    // Inspired by https://github.com/GitbookIO/plugin-styles-less/blob/master/index.js#L8
+    // @Inspiration https://github.com/GitbookIO/plugin-styles-less/blob/master/index.js#L8
     init: function() {
 
       var book = this;
 
       if (book.output.name !== 'ebook') {
-        // Output path is different for websites so just skip the logic below since it
-        // is only valid for ebooks
+        // Logic below does not apply to non-ebook formats
         return;
       }
 
       var outputDirectory = path.join(book.output.root(), '/gitbook/gitbook-plugin-prism');
-      var outputFile = path.resolve(outputDirectory, 'prism-pdf.css');
-      var inputFile = path.resolve(__dirname, './prism-pdf.css');
+      var outputFile = path.resolve(outputDirectory, 'prism-ebook.css');
+      var inputFile = path.resolve(__dirname, './prism-ebook.css');
       mkdirp.sync(outputDirectory);
 
       try {
         fs.writeFileSync(outputFile, fs.readFileSync(inputFile));
       } catch (e) {
-        console.warn('Failed to write prism-pdf.css. See https://git.io/v1LHY for side effects.');
+        console.warn('Failed to write prism-ebook.css. See https://git.io/v1LHY for side effects.');
         console.warn(e);
       }
 

+ 0 - 0
prism-pdf.css → prism-ebook.css