Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rpaul-stripe committed May 9, 2022
0 parents commit cd571c7
Show file tree
Hide file tree
Showing 68 changed files with 12,850 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,29 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true,
"jasmine": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_"
}],
"prefer-const": ["error", {
"destructuring": "all"
}]
},
"ignorePatterns": [ "src/grammar/tag.js", "dist", "build.js"]
}
76 changes: 76 additions & 0 deletions .github/CODE_OF_CONDUCT.md
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at conduct@stripe.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
11 changes: 11 additions & 0 deletions .github/CONTRIBUTING.md
@@ -0,0 +1,11 @@
# Contributing

If you have found a bug or have a feature suggestion, please feel free to [open an issue](https://github.com/markdoc/markdoc/issues).

If you’d like to make changes yourself, follow these steps:

1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository and [clone](https://help.github.com/articles/cloning-a-repository/) it locally
1. Run `npm install`
1. Build the library using `npm run build`
1. Test your changes with `npm test` and `npm run marktest`
1. Finally, submit a [pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,37 @@
name: Bug report
description: Create a report to help us fix Markdoc bugs
labels: ["bug"]
# title: ''
# assignees:
body:
- type: markdown
attributes:
value: Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: When I did this…
validations:
required: true
- type: textarea
id: to-reproduce
attributes:
label: To reproduce
description: Please share steps to reproduce the error or a broken test case.
placeholder: |
1. Create this Markdoc file
2. …
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: What version of `markdoc` are you running?
- type: textarea
id: additional
attributes:
label: Additional context
description: Add any other context about the problem here, including screenshots if applicable.
19 changes: 19 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,19 @@
name: Publish Package to NPM

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/validate.yml
@@ -0,0 +1,21 @@
name: CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16.x
- name: npm install, build, and test
run: |
npm ci
npm run build
npm run prettier:check
npm run lint
npm run type:check
npm run test
npm run marktest
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
node_modules
.DS_Store
.node-version
dist
.vscode/settings.json
3 changes: 3 additions & 0 deletions .prettierrc
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
34 changes: 34 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,34 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run marktest",
"skipFiles": [
"<node_internals>/**"
],
"runtimeArgs": ["-r", "ts-eager/register"],
"console": "integratedTerminal",
"program": "${workspaceFolder}/spec/marktest/index.ts",
"cwd": "${workspaceFolder}/spec/marktest",
"args": ["tests.yaml"]
},
{
"type": "node",
"request": "launch",
"name": "Run marktest at Line",
"skipFiles": [
"<node_internals>/**"
],
"runtimeArgs": ["-r", "ts-eager/register"],
"console": "integratedTerminal",
"program": "${workspaceFolder}/spec/marktest/index.ts",
"cwd": "${workspaceFolder}/spec/marktest",
"args": ["${file}:${lineNumber}"]
}
]
}
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2021- Stripe, Inc. (https://stripe.com)

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.
75 changes: 75 additions & 0 deletions README.md
@@ -0,0 +1,75 @@
<h1 align="center">
<br>
<img src="https://user-images.githubusercontent.com/62121649/166497424-eed74185-92b8-48bf-9d54-493282df288b.png" alt="Markdoc" width="260">
<br>
<br>
</h1>

<h4 align="center">A powerful, flexible, Markdown-based authoring framework.</h4>

Markdoc is a [Markdown](https://commonmark.org)-based syntax and toolchain for creating custom documentation sites and experiences.
We designed Markdoc to power [Stripe's public docs](http://stripe.com/docs), our largest and most complex content site.

## Installation

To get started with Markdoc, first install the library:

```shell
npm install @markdoc/markdoc
```

or

```shell
yarn add @markdoc/markdoc
```

and import it in your app:

```js
const Markdoc = require('@markdoc/markdoc');
```

or if you are using ESM

```js
import Markdoc from '@markdoc/markdoc';
```

then use `Markdoc` in your app or tool:

```js
const doc = `
# Markdoc README
{% image src="/logo.svg" /%}
`;

const ast = Markdoc.parse(doc);
const content = Markdoc.transform(ast);
return Markdoc.renderers.react(content, React);
```

Check out [our docs](https://markdoc.io/docs) for more guidance on how to use Markdoc.

## Contributing

Contributions and feedback are welcome and encouraged. Check out our [contributing guidelines](.github/CONTRIBUTING.md) on how to do so.

### Development

1. Run `npm install`
1. Run `npm build`
1. Run the tests using `npm test`

## Code of conduct

This project has adopted the Stripe [Code of conduct](.github/CODE_OF_CONDUCT.md).

## License

This project uses the [MIT license](LICENSE).

## Credits

Shout out to [@marcioAlmada](https://github.com/marcioAlmada) for providing us with the [@markdoc](https://github.com/markdoc) GitHub org.
15 changes: 15 additions & 0 deletions build.js
@@ -0,0 +1,15 @@
const { buildSync } = require('esbuild');

const shared = {
bundle: true,
entryPoints: ['index.ts'],
outdir: 'dist',
sourcemap: 'external',
external: [],
format: 'esm',
watch: process.argv.includes('--watch'),
};

buildSync({ ...shared, format: 'cjs' });
buildSync({ ...shared, outExtension: { '.js': '.mjs' } });
buildSync({ ...shared, entryPoints: ['src/renderers/react/react.ts'] });
11 changes: 11 additions & 0 deletions global.d.ts
@@ -0,0 +1,11 @@
import type { ValidationError } from './src/types';

declare module 'markdown-it/lib/token' {
export default class Token extends require('markdown-it/lib/token') {
errors?: ValidationError[];
position?: {
start?: number;
end?: number;
};
}
}

0 comments on commit cd571c7

Please sign in to comment.