Code Monkey home page Code Monkey logo

gitdown's People

Contributors

agarzola avatar brettz9 avatar furzeface avatar gajus avatar golopot avatar goooseman avatar techmsi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitdown's Issues

Vulnerability due to dependency on outdated version of "marked" (WS-2020-0163, CVE-2021-21306, CVE-2022-21681)

https://security-tracker.debian.org/tracker/CVE-2022-21681
https://nvd.nist.gov/vuln/detail/CVE-2021-21306
https://snyk.io/test/npm/gitdown

To resolve, gitdown would need to update it's dependency of "marked" to "^4.0.10"

NPM Orverrides are insufficient to solve this problem in the meantime because gitdown uses marked directly as the parse function call. The fixed version of marked requires marked.parse() rather than marked(). Overriding will just cause errors because of that one line in gitdown's code.

These are Regular Expression Denial of Service vulnerabilities. Please upgrade this dependency as many of our packages use gitdown but will be blocked when the SLA on this vulnerability has been exceeded.

Added info on ReDoS: https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS

Error w/ contextify during `npm install --save gitdown`

> [email protected] install /Users/robsawyer/Sites/hubot-artsy/node_modules/gitdown/node_modules/deadlink/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild

  CXX(target) Release/obj.target/contextify/src/contextify.o
  SOLINK_MODULE(target) Release/contextify.node
  SOLINK_MODULE(target) Release/contextify.node: Finished
npm ERR! Error: Command failed: Cloning into bare repository '/Users/robsawyer/.npm/_git-remotes/git-github-com-gajus-contents-fcae7993'...
npm ERR! fatal: unable to connect to github.com:
npm ERR! github.com[0: 192.30.252.129]: errno=Connection refused
npm ERR!
npm ERR!
npm ERR!     at ChildProcess.exithandler (child_process.js:648:15)
npm ERR!     at ChildProcess.emit (events.js:98:17)
npm ERR!     at maybeClose (child_process.js:756:16)
npm ERR!     at Process.ChildProcess._handle.onexit (child_process.js:823:5)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 14.0.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "gitdown"
npm ERR! cwd /Users/robsawyer/Sites/hubot-artsy
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code 128
npm ERR! not ok code 0

TypeError: Cannot call method 'slice' of null

Hi! I’m getting the following error in the console every time I run gulp gitdown-watch (I namespaced the watch task):

[10:53:09] Starting 'gitdown'...
[10:53:09] 'gitdown' errored after 150 ms
[10:53:09] TypeError: Cannot call method 'slice' of null
    at Function.Gitinfo._parseRemoteOriginURL (/Users/agarzola/git/bustime/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:96:37)
    at Gitinfo.gitinfo.username (/Users/agarzola/git/bustime/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:48:24)
    at Gitinfo.gitinfo.url (/Users/agarzola/git/bustime/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:62:48)
    at Object.helper.compile (/Users/agarzola/git/bustime/node_modules/gitdown/src/helpers/gitinfo.js:23:32)
    at Gitdown.gitdown._resolveURLs (/Users/agarzola/git/bustime/node_modules/gitdown/src/gitdown.js:99:33)
    at /Users/agarzola/git/bustime/node_modules/gitdown/src/gitdown.js:35:32
    at tryCatch1 (/Users/agarzola/git/bustime/node_modules/gitdown/node_modules/bluebird/js/main/util.js:45:21)
    at Promise$_callHandler [as _callHandler] (/Users/agarzola/git/bustime/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:660:13)
    at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/Users/agarzola/git/bustime/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:675:18)
    at Promise$_settlePromiseAt [as _settlePromiseAt] (/Users/agarzola/git/bustime/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:845:14)

This happens no matter what is in my .gitdown/README.md; it happens whether my entire readme text is in there, or a single word (“Hello”) or even with an empty file.

I also got the following error warning during installation via npm, in case it’s relevant:

> node-gyp rebuild

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

  CC(target) Release/obj.target/libmagic/deps/libmagic/src/apprentice.o
  CC(target) Release/obj.target/libmagic/deps/libmagic/src/apptype.o
  CC(target) Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o
  CC(target) Release/obj.target/libmagic/deps/libmagic/src/cdf.o
../deps/libmagic/src/cdf.c:303:6: warning: implicit declaration of function 'pread' is invalid in
      C99 [-Wimplicit-function-declaration]
        if (pread(info->i_fd, buf, len, off) != (ssize_t)len)
            ^
1 warning generated.

`get-urls` use of `re2` and compilation

This is an FYI (and to the limited extent I understand it), that after an update on eslint-plugin-jsdoc, apparently due to an issue similar to uhop/node-re2#79 , i.e., the error that re2 "was compiled against a different Node.js version using NODE_MODULE_VERSION 72. This version of Node.js requires NODE_MODULE_VERSION 83", but starting over with node_modules and package-lock.json or adding the solution it references at https://github.com/uhop/node-re2/wiki/Problem:-ABI-mismatch-in-Electron , and https://github.com/uhop/install-artifact-from-github/wiki/Installing to add DEVELOPMENT_SKIP_GETTING_ASSET=1 before the babel-node calls in the check-readme script did not help. I'm using nvm and when I switched back from Node 12 as I was using to Node 14, I was able to get through our husky hook (which uses gitdown) without complaint.

Just a heads up since the dependency chain of gitdown, get-urls -> url-regex-safe -> re2 leads to re2 and others may run into this issue. I'm not sure any other action is called for.

Including gists

It would be nice to have {"gitdown": "gist", "id": "", "fileName": ""} Gitdown JSON hook.

Bug to convert title with number format

In file: gitdown/src/gitdown.js
Line 308 to 314

Source code:

// `test`
normalizedName = _.trim(marked(normalizedName));

// <p><code>test</code></p>
normalizedName = normalizedName.slice(3, -4);

// <code>test</code>

===

The conversion is incorrect if the title like this: 1. Title one
Raw markdown: ## 1. Title one
Expected raw output: ## 1.Title one
Expected user view: 1. Title one

Actual error result:

// `1. Title one`
normalizedName = _.trim(marked(normalizedName));

// <ol>\n<li>1. Title one</li>\n</ol>
normalizedName = normalizedName.slice(3, -4);

// >\n<li>Title one</li>\n<

===

Missing "#!/usr/bin/env node"

Missing #!/usr/bin/env node in ./src/bin/index.js.

Without that you will get:

./node_modules/.bin/gitdown: line 1: use strict: command not found
./node_modules/.bin/gitdown: line 3: var: command not found
./node_modules/.bin/gitdown: line 4: argv,: command not found
./node_modules/.bin/gitdown: line 5: subject,: command not found
./node_modules/.bin/gitdown: line 6: _,: command not found
./node_modules/.bin/gitdown: line 7: fileExists: command not found
./node_modules/.bin/gitdown: line 9: syntax error near unexpected token `('
./node_modules/.bin/gitdown: line 9: `yargs = require('yargs');'

Make deadlink an optional dependency

Deadlink is taking a lot of space and annoyingly long time to build. Make it an optional dependency.

 15M    ./gitdown/deadlink
 20K    ./gitdown/filesize
280K    ./gitdown/gitinfo
436K    ./gitdown/glob
 24K    ./gitdown/jsonfile
680K    ./gitdown/markdown-contents
 28K    ./gitdown/stack-trace
132K    ./gitdown/url-extractor

Branch ("develop") definition does not exist in the config.

Hi @gajus, thanks for creating this.

I'm trying this for the first time and having some problems I could use some help with please.

I created the following in a Gruntfile.js.

grunt.registerTask('gitdown', 'Generate README using gitdown.', function() {

  var Gitdown = require('gitdown');
  var gitdown = Gitdown.read('.gitdown/README.md');

  gitdown.write('README.md');

});

Which can be run with grunt gitdown.

I'm on the develop branch of a local clone of https://github.com/JamieMason/Jasmine-Matchers/tree/develop and the contents of my .gitdown/README.md don't seem to matter, I receive the following error.

Running "gitdown" task

Possibly unhandled Error: Branch ("develop") definition does not exist in the config.
    at Gitinfo.gitinfo.remoteURL (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:65:19)
    at Gitinfo.gitinfo.username (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:92:54)
    at Gitinfo.gitinfo.url (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:21:48)
    at Object.helper.compile (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/src/helpers/gitinfo.js:23:32)
    at Gitdown.gitdown._resolveURLs (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/src/gitdown.js:99:33)
    at /Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/src/gitdown.js:35:32
    at tryCatcher (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._settlePromiseFromHandler (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:475:31)
    at Promise._settlePromiseAt (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:554:18)
    at Async._drainQueue (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/bluebird/js/main/async.js:84:12)
    at Async._drainQueues (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/bluebird/js/main/async.js:89:10)
    at Async.drainQueues (/Users/jamie/Sites/Jasmine-Matchers/node_modules/gitdown/node_modules/bluebird/js/main/async.js:14:14)
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:902:3

Done, without errors.

The value of gitdown.config is.

{
  headingNesting: {
    enabled: true
  },
  variable: {
    scope: {}
  },
  deadlink: {
    findDeadURLs: false,
    findDeadFragmentIdentifiers: false
  },
  gitinfo: {
    gitPath: '/Users/jamie/Sites/Jasmine-Matchers'
  }
}

Add dependency badges.

I use https://david-dm.org/ for showing up-to-date dependencies/devDependencies badges on the majority of my READMEs. Could be useful.

Syntax is something like:

[![devDependency Status](https://david-dm.org/furzeface/daniel.furzeface.com/dev-status.svg?style=flat)](https://david-dm.org/furzeface/daniel.furzeface.com#info=devDependencies)

Error: Cannot get the current branch name

My local builds work fine, but my travis-ci builds give me this error:

[email protected] gitdown /home/travis/build/billmoser/examples-plugin-jsdoc
gitdown ./.README/README.md --output-file ./README.md
(node:5304) UnhandledPromiseRejectionWarning: Error: Cannot get the current branch name.
at Object.gitinfo.getBranchName (/home/travis/build/billmoser/examples-plugin-jsdoc/node_modules/gitinfo/dist/gitinfo.js:85:11)
at Object.gitinfo.getRemoteUrl (/home/travis/build/billmoser/examples-plugin-jsdoc/node_modules/gitinfo/dist/gitinfo.js:94:32)
at Object.gitinfo.getUsername (/home/travis/build/billmoser/examples-plugin-jsdoc/node_modules/gitinfo/dist/gitinfo.js:132:53)
at Object.gitinfo.getGithubUrl (/home/travis/build/billmoser/examples-plugin-jsdoc/node_modules/gitinfo/dist/gitinfo.js:51:44)
at Object.helper.compile (/home/travis/build/billmoser/examples-plugin-jsdoc/node_modules/gitdown/dist/helpers/gitinfo.js:36:41)
at Object.gitdown.resolveURLs (/home/travis/build/billmoser/examples-plugin-jsdoc/node_modules/gitdown/dist/gitdown.js:111:35)
at Object.gitdown.get (/home/travis/build/billmoser/examples-plugin-jsdoc/node_modules/gitdown/dist/gitdown.js:54:19)
at async Object.gitdown.writeFile (/home/travis/build/billmoser/examples-plugin-jsdoc/node_modules/gitdown/dist/gitdown.js:66:26)
(Use node --trace-warnings ... to show where the warning was created)
(node:5304) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5304) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

there seems to be a parameter called config.defaultBranchName that might be applicable here, but I have no idea how to use it in my README.md

Allow to inject variables

Original feature request:

I love the idea! I could certainly see myself using this.
Shameless feature request: variable interpolation using values in package.json or some other easy-to modify-programmatically file. In the past I've used html comments to identify where these values should go, so that the template and rendered output could be the same file.

Kibana 4.0.0-BETA2

From: https://github.com/elasticsearch/kibana/blob/master/README.md

– http://www.reddit.com/r/javascript/comments/2mgzxe/gitdown_markdown_preprocessor_for_github_early/cm4s3zm

breaking changes: 1.3.1/1.3.2

I have just upgraded to 1.3.2 and it doesn't work. It looks like you have made breaking changes on 1.3.1.

I have got the following error:

TypeError: undefined is not a function
    at Function.MarkdownContents.tree (~/webpack-config/node_modules/gitdown/node_modules/markdown-contents/src/markdown-contents.js:98:21)
    at Function.Gitdown._nestHeadingIds (~/webpack-config/node_modules/gitdown/src/gitdown.js:268:47)
    at ~/webpack-config/node_modules/gitdown/src/gitdown.js:36:40
    at tryCatcher (~/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (~/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise._settlePromiseAt (~/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:581:18)
    at Async._drainQueue (~/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/async.js:128:12)
    at Async._drainQueues (~/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (~/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:367:17)

Crashes on new branch

When creating a new branch, which consequently has no remote branch, I get this behavior:

npx gitdown ./README_src.md --output-file ./README.md
Unhandled rejection Error: Branch ("issue-36") definition does not exist in the config.

This has previously been noted in #27 but closed without change. I think, this is undesirable behavior.

I'd like to get a more understandable error message instead of an exception, if failure is the expected behavior for new branches. Ideally, I'd like this to work for new branches as well, but since git itself won't setup tracking without the remote branch, that's probably out of scope for gitdown.

It would be nice to get a warning if no URLs are needed, but an error when this prevents building.

Also, when the README file cannot be updated, gitdown should fail with a non-zero exit code. My use-case is that gitdown updates my README.md from a README.src.md via commit hook. If that goes through despite not doing its work, that is a recipe for disaster.

Notice breaks Jekyll markdown pages

The auto generated notice breaks the YAML frontmatter when using Jekyll to convert a markdown file to HTML:


---
layout: index
title: Home
permalink: /

---

Generates:

<!--
This file has been generated using Gitdown (https://github.com/gajus/gitdown).
Direct edits to this will be be overwritten. Look for Gitdown markup file under ./.gitdown/ path.
-->

---
layout: index
title: Home
permalink: /

---

And will make Jekyll ignore that file (since it does not start with the frontmatter). I hacked it with setting Gitdown.notice = function() { return ''; };.

I can think of two solutions:

  1. Make the notice a plugin (with customizable text) and add the standard notice if the plugin hasn't been used.
  2. Insert the notice after the second --- if the file starts with it.

Make a live editor available

Make an editor that would preview files processed using Gitdown. This could show 4 windows: Gitdown markup, generated Github markup, HTML and the actual preview. It would be a useful learning and debugging tool.

Some challenges to consider is the configurable Gitdown behaviour, inclusion of external files and use of user defined helpers. The latter is an issue because Gitdown is processed on the server side. Simple solution would be to restrict some of the features.

Setting config doesn't work?

var gitdown = require('gitdown');
var config = gitdown.config;
config.gitinfo.gitPath = './docs';
gitdown.config = config;

results in error:

config.gitinfo.gitPath = './docs';
      ^
TypeError: Cannot read property 'gitinfo' of undefined

This seems to be what is documented in the README for gitdown, but doesn't seem to be working. Am I doing something wrong? This is in gulp.

Error: Input file does not exist.

@gajus

I got error:

Error: Input file does not exist.
    at Object.helper.compile (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/src/helpers/include.js:30:15)
    at /Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/src/parser.js:184:54
    at Array.forEach (native)
    at parser.execute (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/src/parser.js:173:30)
    at parser.play (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/src/parser.js:49:22)
    at /Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/src/parser.js:60:31
    at tryCatcher (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise._settlePromiseAt (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:581:18)
    at Promise._settlePromises (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/promise.js:697:14)
    at Async._drainQueue (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/mdreizin/Developer/src/github.com/webpack-config/node_modules/gitdown/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

using the following snippet:

gulp.task('docs-readme', function() {
    return Gitdown.readFile(path.resolve('./.gitdown/README.md')).writeFile(path.resolve('./README.md'));
});
node v5.6.0
npm v3.6.0
"gitdown": "^2.4.0",

appveyor badge is broken

@gajus You have refactored code. I liked style=flat-square, but now it uses wrong url:

AppVeyor build status
It should use:

AppVeyor build status

When you have travis and appveyor it is difficult to detect them, because they have the same picture:

Travis build status
AppVeyor build status

It would be nice to add logo for appveyor:

AppVeyor build status

or add label

AppVeyor build status

Travis build status

CodeClimate.com badges

They have a GPA (grading) badge as well as a test coverage badge. I wouldn’t mind working on this, if you don’t mind a pull request.

Add ability to inject part of the code

Example, if I want to include this fragment

gitdown/src/gitdown.js

Lines 27 to 50 in 12c91a4

/**
* Process template.
*
* @returns {Promise}
*/
gitdown.get = () => {
return parser
.play(input)
.then((state) => {
let markdown;
markdown = state.markdown;
if (gitdown.getConfig().headingNesting.enabled) {
markdown = Gitdown.nestHeadingIds(markdown);
}
return gitdown
.resolveURLs(markdown)
.then(() => {
return markdown.replace(/<!--\sgitdown:\s(:?off|on)\s-->/g, '');
});
});
};

I would surround the code fragment with comments such as:

// gitdown-template-start: foo-fragment
/**
 * Process template.
 *
 * @returns {Promise}
 */
gitdown.get = () => {
  return parser
    .play(input)
    .then((state) => {
      let markdown;

      markdown = state.markdown;

      if (gitdown.getConfig().headingNesting.enabled) {
        markdown = Gitdown.nestHeadingIds(markdown);
      }

      return gitdown
            .resolveURLs(markdown)
            .then(() => {
              return markdown.replace(/<!--\sgitdown:\s(:?off|on)\s-->/g, '');
            });
    });
};
// gitdown-template-end: foo-fragment

where "foo-fragment" is name of the fragment.

Then this snippet can be included into a README document using:

{"gitdown": "snippet", "file": "./src/gitdown.js", "name": "foo-fragment"}

This would be used to inject type declarations, etc. to documentation without needing to repeat them.

"Cannot get the current branch name." on travis-ci

Could you please tell me how to find workaround for that?

travis-ci uses:

git clone --depth=50 --branch=master https://github.com/mdreizin/webpack-config.git mdreizin/webpack-config
cd mdreizin/webpack-config
git checkout -qf 9ccb6cdb8cba6519d38df68d2b785ee7cf0aeab2
npm run doc
Error: Cannot get the current branch name.
    at Object.gitinfo.branch (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:51:19)
    at Object.gitinfo.remoteURL (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:63:34)
    at Object.gitinfo.username (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/node_modules/gitinfo/src/gitinfo.js:98:51)
    at Object.helper.compile (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/src/helpers/gitinfo.js:25:32)
    at Object.services.travis (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/src/helpers/badge.js:98:34)
    at Object.helper.compile (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/src/helpers/badge.js:150:33)
    at /home/travis/build/mdreizin/webpack-config/node_modules/gitdown/src/parser.js:184:54
    at Array.forEach (native)
    at Parser.parser.execute (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/src/parser.js:173:30)
    at Parser.parser.play (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/src/parser.js:49:22)
    at Gitdown.gitdown.get (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/src/gitdown.js:31:14)
    at Gitdown.gitdown.write (/home/travis/build/mdreizin/webpack-config/node_modules/gitdown/src/gitdown.js:55:14)
    at Gulp.<anonymous> (/home/travis/build/mdreizin/webpack-config/gulpfile.js:20:47)
    at module.exports (/home/travis/build/mdreizin/webpack-config/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/travis/build/mdreizin/webpack-config/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/travis/build/mdreizin/webpack-config/node_modules/gulp/node_modules/orchestrator/index.js:214:10)

Make unique heading IDs

# foo
## download
# bar
## download

Will generate:

<h1 id="foo">foo</h1>
<h2 id="download">download</h2>
<h1 id="bar">bar</h1>
<h2 id="download">download</h2>

Which has duplicate "download" IDs. We can make them unique by prefixing the parent heading ID, e.g.

<h1 id="foo">foo</h1>
<h2 id="foo-download">download</h2>
<h1 id="bar">bar</h1>
<h2 id="bar-download">download</h2>

Support for raw links and URL encoding

When adding a "Deploy to Azure" button in a README.md file, the reference that's used needs to be to an ARM template (JSON) file in the repository, but the raw file needs to be referenced. In addition, because the URL to the ARM template is specified as a query string parameter, the URL needs to be encoded.

This leads to hardcoding the raw URL, which includes the branch name, etc.

It would be nice if gitdown had two additional options:

  1. Generate a link to a raw file in the current repo, current branch.
  2. URL encode the link.

For the docs on creating a "Deploy to Azure" button see https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-to-azure-button.

Where do you register a Custom Helper?

gitdown.registerHelper('my-helper-name', {
    /**
     * @var {Number} Weight determines the processing order of the helper function. Default: 10.
     */
    weight: 10,
    /**
     * @param {Object} config JSON configuration.
     * @return {mixed|Promise}
     */
    compile: function (config) {
        return 'foo: ' + config.foo;
    }
});

Support for links on npm

In making a document which also works on npmjs.com, we need support for links which are prefixed with user-content-. GitHub supports this prefix in addition to unprefixed ones, while npmjs.com requires it.

For example with eslint-plugin-jsdoc, the Markdown Settings heading gets turned into the anchor user-content-settings, and the HTML anchor eslint-plugin-jsdoc-settings becomes user-content-eslint-plugin-jsdoc-settings with no other anchors available.

I'm guessing the article ID passed on to your contents generators may need to be prefixed with user-content-.

This would fix our gajus/eslint-plugin-jsdoc#707

codeclimate

Override github project for build badge

Hello 🙂
I've included gitdown in check-node-version for having nicer READMEs.
Since I'm not the original author, I work under a different repo url.

Now, after merging into the original repo, the build badges are wrong because they point to my branch. That was easy to fix, of course, but I'd like to be able have them point at the base repo at build time.

Is that currently possible from within gitdown? If not, I'd like to request that feature.

Add an option to "include" function to increment headings

Add an option to the include file function that would increment heading size of the document being included to the size of the host section heading.

Example:

Source README.md:

# README

## Section where LICENSE is included

{"gitdown": "include", "file": "./LICENSE.md","adjustHeading":"contain"}

Source LICENSE.md:

# LICENSE

Foo

## bar

Bar

Current output:

# README

## Section where LICENSE is included

# LICENSE

Foo

## bar

Bar

Desired output:

# README

## Section where LICENSE is included

### LICENSE

Foo

### bar

Bar

Use ESHint

Remove "jshint" dev dependency from package.json and the gulp task.

sh:

npm install gulp-eslint --save-dev

gulpfile.js:

var eslint = require('gulp-eslint');

gulp.task('lint', function () {
    return gulp
        .src(['./src/*.js', './src/cinemas/*/*.js', './tests/*.js'])
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failOnError());
});

.eslintrc:

{
    "rules": {
        "no-console": 0,
        "no-extra-parens": 2,
        "no-reserved-keys": 2,
        "no-eq-null": 2,
        "no-extend-native": 2,
        "no-process-env": 2,
        "no-self-compare": 2,
        "no-void": 2,
        "no-warning-comments": [1, { "terms": ["todo", "@toto"], "location": "start" }],
        "vars-on-top": 2,
        "wrap-iife": [2, "inside"],
        "global-strict": [2, "always"],
        "new-cap": 0,
        "no-shadow": 0,
        "no-mixed-requires": 0,
        "no-new-require": 2,
        "brace-style": [2, "1tbs"],
        "comma-style": [2, "last"],
        "func-style": [2, "expression"],
        "no-inline-comments": 2,
        "no-lonely-if": 2,
        "no-multiple-empty-lines": 2,
        "no-nested-ternary": 2,
        "one-var": 2,
        "operator-assignment": [2, "always"],
        "padded-blocks": [2, "never"],
        "quote-props": [2, "as-needed"],
        "quotes": [2, "single"],
        "space-after-keywords": [2, "always"],
        "space-before-blocks": [2, "always"],
        "space-in-brackets": [2, "never"],
        "space-in-parens": [2, "never"],
        "space-unary-ops": [2, { "words": true, "nonwords": false }],
        "spaced-line-comment": [2, "always"],
    },
    "env":{
        "mocha": true,
        "node": true
    }
}

Cannot find module 'url-extractor'

Please update README to handhold n00bs thru installing pre-requisites.
I am evidently missing some subtle aspect of installing gitdown/
You can reproduce the issue as follows:

$ sudo npm install gitdown -g
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.23.2/install.sh | bash
$ nvm install iojs
$ npm install url-extractor
$ gitdown ./foo.gd --output-file ./foo.md
Error: Cannot find module 'url-extractor'
$ cat foo.gd 
{"gitdown": "include", "file": " "./wheeler.sh"}
cat wheeler.sh
#!/bin/sh
#
#       wheeler.sh
#       add wheel group to acl
#
if [ $UID -ne 0 ]; then
    echo "Superuser/root privileges are required to run this script."
    echo "e.g. \"sudo $0\""
    exit 1
fi
chgrp -R wheel $1
chmod -R g+rwx $1

Invalid remote origin URL in non-Github repo

I was looking into using gitdown for a thing. However, I'm working with an Azure DevOps repository, which is triggering an edge case.

The thing that is tripping me up right now is the error below thrown by gitinfo. I've anonymized some values in the stack trace ;)

Error: Invalid remote origin URL ("https://{organization_name}@dev.azure.com/{organization_name}/{project_name}/_git/{repository_name}").
    at parseRemoteOriginUrl ({repo_root}\node_modules\gitinfo\dist\utils.js:74:11)
    at Object.gitinfo.getUsername ({repo_root}\node_modules\gitinfo\dist\gitinfo.js:132:44)
    at Object.gitinfo.getGithubUrl ({repo_root}\node_modules\gitinfo\dist\gitinfo.js:51:44)
    at Object.helper.compile ({repo_root}\node_modules\gitdown\dist\helpers\gitinfo.js:36:41)
    at Object.gitdown.resolveURLs ({repo_root}\node_modules\gitdown\dist\gitdown.js:111:35)
    at Object.gitdown.get ({repo_root}\node_modules\gitdown\dist\gitdown.js:54:19)
    at async Object.gitdown.writeFile ({repo_root}\node_modules\gitdown\dist\gitdown.js:66:26)

I have no interest in using this functionality and have not included any of the gitinfo things in the Markdown files. However, it still tries to gather the information with the error as a result. I have not found an option to simply disable gitinfo altogether.

I've taken a look at the source code of gitinfo (different repo, I know) and it assumes a Github repo. That makes it a very good idea to allow gitdown users to disable the gitinfo parsing imo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.