Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Conversation

@clinejm
Copy link
Contributor

@clinejm clinejm commented Jul 21, 2018

No description provided.

Copy link
Contributor

@indexzero indexzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start – added some additional test cases that I've seen in the wild.


# a `code block` in the header


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other important test cases:

# Other punctuation, such as d.o.t.s, commas 

# Emdash –– and dash --

# Ampersand &

# Backslashes// or slashes\\

# Complex code blocks like `/foo/bar/:bazz?buzz=foo`

# Bold formatting **like this**

# Italic formatting _like this_

# All !@# the $%^ colors &*( of ){} the |~ punctuation < "' rainbow += 

# Seriously all of them ... Alt + [q-|] œ∑´®†¥¨ˆøπ“‘«

Might make more sense to have a more structured file (like a CSV of two columns output,input) e.g.

#test,# test
# 2 starts with number,#2-starts-with-number

Then you could generate the real .md file from that CSV as part of npm pretest or npm posttest (since we need it to verify what Github actually does since this algorithm is not part of the official GFM specification)

@indexzero
Copy link
Contributor

FYI did more digging on GFM itself:

@clinejm clinejm changed the title WIP improving headline slugging to be more GH compliant. improving headline slugging to be more GH compliant. Jul 24, 2018
Copy link

@dusave dusave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you export this from the package so we can leverage the slugifier in our own renderers?

if (this.slugs[slug]) {
uniqueSlug = `${slug}-${this.slugs[slug]}`;
}
this.slugs[slug] += 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we save this.slugs[slug] in a local const? I think it would allow it to read cleaner.

const numOccurances = this.slugs[slug] || 0;
if (numOccurances) {
  uniqueSlug = `${slug}-${numOccurances}`;
}
this.slugs[slug] += 1;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe change slugs to slugCounts?

package.json Outdated
"browser": "lib/index.js",
"module": "src/index.js",
"main": "./index.js",
"browser": "./index.js",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't main and browser still be lib/index.js?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. index.js should probably be src/index.js

assume(tree.find('#codething-in-the-header-morecode-txt')).to.have.length(1);
assume(tree.find('#codething-in-the-header-morecode-txt')
.find('a').prop('href')).is.equal('#codething-in-the-header-morecode-txt');
assume(tree.find('#codething--in-the-header-morecode--txt')).to.have.length(1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we assuming to have --? That seems like a bug to me.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, if we run into a double space, or a character that can't resolve, I would prefer to reduce the - to a single for each, rather than multiple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check what GH is doing to ensure we match

indexzero and others added 2 commits July 26, 2018 12:10
* [refactor dist] Move `src/index.js` to `src/component.js`

* [refactor dist] Move index.js to src/index.js

* [fix dist] Update main, browser, & module.
src/index.js Outdated
import GithubSlugify from './gh-slugify';
import URL from 'url-parse';
import ReactMarkdownGithub from 'src/component.js';
import GithubSlugify from 'src/gh-slugify.js';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be ./component and ./gh-slugify?

@clinejm clinejm merged commit a1cb631 into master Jul 27, 2018
@clinejm clinejm deleted the slug-fixes branch July 27, 2018 20:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants