You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by dblotsky <gi...@git.apache.org> on 2016/02/26 02:55:24 UTC

[GitHub] cordova-docs pull request: Docs Touch-Up

GitHub user dblotsky opened a pull request:

    https://github.com/apache/cordova-docs/pull/523

    Docs Touch-Up

    - Refactoring front matter merging
    - Moving some functionality into util.js
    - Reverting some unintended gulpfile changes
    - Removing Segoe UI from font-family
    - Making doc ToC slightly less bold

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/MSOpenTech/cordova-docs dblotsky-refactor

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-docs/pull/523.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #523
    
----
commit e504efab6fc281a9d21b3f7e91b181b769617d87
Author: Dmitry Blotsky <dm...@gmail.com>
Date:   2016-02-25T03:27:33Z

    Refactoring front matter merging, moving some functionality into util.js. Reverting some unintended gulpfile changes. Removing Segoe UI from font-family and making doc ToC slightly less bold.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: Docs Touch-Up

Posted by nikhilkh <gi...@git.apache.org>.
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/523#discussion_r54315457
  
    --- Diff: tools/bin/util.js ---
    @@ -22,45 +22,93 @@ module.exports = function () {
         var fs   = require("fs");
         var path = require("path");
     
    -    return {
    +    function stripFrontMatter(text) {
    +
    +        // get and replace front matter if it's there
    +        // NOTE:
    +        //      String.replace() replaces only the first occurrence
    +        //      of a string, which is what we want
    +        var rawFrontMatterString = getRawFrontMatterString(text);
    +        if (rawFrontMatterString !== null) {
    +            return text.replace(rawFrontMatterString, "");
    +        }
     
    -        stripFrontMatter: function(text) {
    +        return text;
    +    }
     
    -            var marker = "---";
    +    function getFrontMatterString(text) {
    +        var rawFrontMatterString = getRawFrontMatterString(text);
    +        if (rawFrontMatterString !== null) {
     
    -            var firstMarker = text.indexOf(marker);
    -            if (firstMarker === (-1)) {
    -                return text;
    -            }
    +            // strip out front matter markers
    +            var frontMatterString = rawFrontMatterString.replace(/^---\s*$/gm, "")
    +            return frontMatterString;
    +        }
     
    -            var secondMarker = text.indexOf(marker, firstMarker + marker.length);
    -            var start        = secondMarker + marker.length;
    +        return null;
    +    }
     
    -            return text.slice(start);
    -        },
    +    function setFrontMatterString(text, frontMatterString) {
    +        var textOnly = stripFrontMatter(text);
    +        var newText  = "---\n" + frontMatterString + "---\n\n" + textOnly;
    +        return newText;
    +    }
     
    -        listdirsSync: function (root) {
    -            return fs.readdirSync(root).filter(function(fileName) {
    -                return fs.statSync(path.join(root, fileName)).isDirectory();
    -            });
    -        },
    +    function getRawFrontMatterString(text) {
    +        // NOTE:
    +        //      [\s\S]  matches all characters
    +        //      *?      non-greedy *-match
    +        var match = text.match(/^(---\s*\n[\s\S]*?\n---\s*\n)[\s\S]*$/);
    --- End diff --
    
    This might not work with Windows line endings. Here's another approach to doing this: https://github.com/jxson/front-matter/blob/master/index.js



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: Docs Touch-Up

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on the pull request:

    https://github.com/apache/cordova-docs/pull/523#issuecomment-189076643
  
    @nikhilkh @riknoll please review this when you have a moment.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: Docs Touch-Up

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/523#discussion_r54315923
  
    --- Diff: tools/bin/util.js ---
    @@ -22,45 +22,93 @@ module.exports = function () {
         var fs   = require("fs");
         var path = require("path");
     
    -    return {
    +    function stripFrontMatter(text) {
    +
    +        // get and replace front matter if it's there
    +        // NOTE:
    +        //      String.replace() replaces only the first occurrence
    +        //      of a string, which is what we want
    +        var rawFrontMatterString = getRawFrontMatterString(text);
    +        if (rawFrontMatterString !== null) {
    +            return text.replace(rawFrontMatterString, "");
    +        }
     
    -        stripFrontMatter: function(text) {
    +        return text;
    +    }
     
    -            var marker = "---";
    +    function getFrontMatterString(text) {
    +        var rawFrontMatterString = getRawFrontMatterString(text);
    +        if (rawFrontMatterString !== null) {
     
    -            var firstMarker = text.indexOf(marker);
    -            if (firstMarker === (-1)) {
    -                return text;
    -            }
    +            // strip out front matter markers
    +            var frontMatterString = rawFrontMatterString.replace(/^---\s*$/gm, "")
    +            return frontMatterString;
    +        }
     
    -            var secondMarker = text.indexOf(marker, firstMarker + marker.length);
    -            var start        = secondMarker + marker.length;
    +        return null;
    +    }
     
    -            return text.slice(start);
    -        },
    +    function setFrontMatterString(text, frontMatterString) {
    +        var textOnly = stripFrontMatter(text);
    +        var newText  = "---\n" + frontMatterString + "---\n\n" + textOnly;
    +        return newText;
    +    }
     
    -        listdirsSync: function (root) {
    -            return fs.readdirSync(root).filter(function(fileName) {
    -                return fs.statSync(path.join(root, fileName)).isDirectory();
    -            });
    -        },
    +    function getRawFrontMatterString(text) {
    +        // NOTE:
    +        //      [\s\S]  matches all characters
    +        //      *?      non-greedy *-match
    +        var match = text.match(/^(---\s*\n[\s\S]*?\n---\s*\n)[\s\S]*$/);
    --- End diff --
    
    Good catch! I forgot about the `\r`s. Will add them back.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: Docs Touch-Up

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-docs/pull/523


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org