{"id":20714157,"url":"https://github.com/ksky521/hulk-markdown-loader","last_synced_at":"2026-04-22T01:02:21.681Z","repository":{"id":57269525,"uuid":"201849448","full_name":"ksky521/hulk-markdown-loader","owner":"ksky521","description":"专门给 Component 命令使用的 markdown loader，会将 markdown 文档中的 demo 部分代码解析出来，生成可展现的San 组件","archived":false,"fork":false,"pushed_at":"2022-01-11T03:40:22.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T12:51:48.126Z","etag":null,"topics":["markdown-loader","san"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ksky521.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-12T03:14:38.000Z","updated_at":"2023-02-17T01:05:45.000Z","dependencies_parsed_at":"2022-09-02T02:01:57.370Z","dependency_job_id":null,"html_url":"https://github.com/ksky521/hulk-markdown-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ksky521/hulk-markdown-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksky521%2Fhulk-markdown-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksky521%2Fhulk-markdown-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksky521%2Fhulk-markdown-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksky521%2Fhulk-markdown-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ksky521","download_url":"https://codeload.github.com/ksky521/hulk-markdown-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksky521%2Fhulk-markdown-loader/sbom","scorecard":{"id":571422,"data":{"date":"2025-08-11","repo":{"name":"github.com/ksky521/hulk-markdown-loader","commit":"3b21eb60966de6dc826fea147bf6258add48861c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 1/16 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T16:27:15.313Z","repository_id":57269525,"created_at":"2025-08-20T16:27:15.313Z","updated_at":"2025-08-20T16:27:15.313Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32116514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"ssl_error","status_checked_at":"2026-04-22T00:30:22.894Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markdown-loader","san"],"created_at":"2024-11-17T02:30:02.822Z","updated_at":"2026-04-22T01:02:21.655Z","avatar_url":"https://github.com/ksky521.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hulk-markdown-loader\n\n专门给 Component 命令使用的 markdown loader，会将 markdown 文档中的 demo 部分代码解析出来，生成可展现的 [San](https://baidu.github.io/san/) 组件。\n\n## Usage\n\n```js\n{\n    test: /\\.md$/,\n    use: [{loader: 'hulk-markdown-loader': options: {template: 'path.template'}}]\n}\n```\n\n## template 说明\n\n支持自定义 template，默认 template 为：\n\n```html\n\u003ctemplate\u003e\n    \u003csection class=\"code-box {{isExpand?'expand':''}}\" id=\"${id}\"\u003e\n        \u003csection class=\"code-box-demo\"\u003e\u003ccode-preview /\u003e\u003c/section\u003e\n        \u003csection class=\"code-box-meta markdown\"\u003e\n            \u003ctext-container-placeholder /\u003e\n            \u003cspan class=\"code-expand-icon\" on-click=\"toggleExpand\"\u003e\n                \u003cimg\n                    alt=\"expand code\"\n                    src=\"https://gw.alipayobjects.com/zos/rmsportal/wSAkBuJFbdxsosKKpqyq.svg\"\n                    class=\"{{isExpand?'code-expand-icon-hide':'code-expand-icon-show'}}\"\n                /\u003e\n                \u003cimg\n                    alt=\"expand code\"\n                    src=\"https://gw.alipayobjects.com/zos/rmsportal/OpROPHYqWmrMDBFMZtKF.svg\"\n                    class=\"{{isExpand?'code-expand-icon-show':'code-expand-icon-hide'}}\"\n                /\u003e\n            \u003c/span\u003e\n        \u003c/section\u003e\n        \u003csection class=\"highlight-wrapper {{isExpand?'highlight-wrapper-expand':''}}\"\u003e\n            \u003ccode-container-placeholder /\u003e\n        \u003c/section\u003e\n    \u003c/section\u003e\n\u003c/template\u003e\n\u003cscript\u003e\n    export default {\n        initData() {\n            return {\n                isExpand: false\n            };\n        },\n        toggleExpand() {\n            this.data.set('isExpand', !this.data.get('isExpand'));\n        }\n    };\n\u003c/script\u003e\n```\n\n特殊标签说明：\n\n-   `\u003ccode-preview/\u003e`： markdown 中的 `fence`部分 san 代码会被渲染出来的效果\n-   `\u003ctext-container-placeholder/\u003e`： markdown 中`text`标签内部的文案转 html\n-   `\u003ccode-container-placeholder/\u003e`：markdown 中的 `fence`部分 san 代码，被 prismjs 语法高亮\n\n## 参数\n\n-   ignore：正则忽略\n-   template：模板路径\n-   context：目录上下文\n-   textTag = 'text'：匹配 text 的 tag，支持 i18n 写法：`\u003ctext lang='cn'\u003e`\n-   i18n = 'cn'：默认解析的文档语言\n-   exportType： 支持三种，默认是 app，即\n    -   app：默认，即通常的用法，会返回`template`转成的 doc+预览的效果，可以修改 template 模板的方式来修改样式\n    -   object：返回的是包含 text、sanComponent 和 code 的对象，在`index.js`中可以自由使用灵活度较高；\n    -   component：仅仅返回 markdown 文档中的代码部分 san 组件，用于只显示预览效果。\n\n## 只展现`html`中的代码，不显示页面文档内容\n\n新建`preview.js`，内容如下：\n\n```js\n// html:\nimport {Component} from 'san';\nimport Basic from './basic.md?exportType=component';\n\nexport default class Index extends Component {\n    static template = `\n        \u003cdiv\u003e\n            \u003cbasic/\u003e\n        \u003c/div\u003e\n    `;\n    static components = {\n        basic: Basic\n    };\n}\n```\n\n在这里`import Basic from './basic.md?exportType=component'`得到的是不再是一个完整的文档+预览内容，而是得到预览部分代码的的 San 组件，通过这种方式可以直接预览 Markdown 文档中的代码部分效果。**可以用于移动页面嵌入 iframe 预览效果**\n\n## 如果组件使用了 ts 语法，需要完善相应 loader 配置\n\n假设有个`ts-comp.san`文件，script内容如下：\n\n```html\n\u003cscript lang=\"ts\"\u003e\nimport {Component} from 'san';\n\nconst text: string = 'Hello TS!';\n\nexport default class TsComp extends Component {\n    static template = `\n        \u003cdiv\u003e{{ text }}\u003c/div\u003e\n    `;\n\n    initData() {\n        return {\n            text\n        };\n    }\n}\n\u003c/script\u003e\n```\n\n那么 webpack 配置文件中需要包括：\n\n```js\n{\n    module: {\n        rules: [\n            {\n                test: /\\.md/,\n                use: 'hulk-markdown-loader'\n            },\n            {\n                test: /\\.san$/,\n                use: 'san-loader'\n            },\n            {\n                test: /\\.ts$/,\n                exclude: /node_modules/,\n                use: {\n                    loader: 'babel-loader',\n                    options: {\n                        presets: [\n                            ...babelConfig.presets,\n                            ['@babel/preset-typescript', {\n                                allExtensions: true\n                            }]\n                        ],\n                        plugins: babelConfig.plugins\n                    }\n                }\n            },\n            {\n                test: /\\.js$/,\n                exclude: /node_modules/,\n                use: {\n                    loader: 'babel-loader',\n                    options: babelConfig\n                }\n            },\n            {\n                test: /\\.(css|less)$/,\n                oneOf: [\n                    // 这里匹配 `\u003cstyle lang=\"less\" module\u003e`\n                    {\n                        resourceQuery: /module/,\n                        use: [\n                            'style-loader',\n                            {\n                                loader: 'css-loader',\n                                options: {\n                                    modules: {\n                                        localIdentName: '[local]_[hash:base64:5]'\n                                    },\n                                    localsConvention: 'camelCase'\n                                }\n                            },\n                            'less-loader'\n                        ]\n                    },\n                    // 这里匹配 `\u003cstyle lang=\"less\"\u003e`\n                    {\n                        use: [\n                            'style-loader',\n                            'css-loader',\n                            'less-loader'\n                        ]\n                    }\n                ]\n            }\n            {\n                test: /\\.html$/,\n                use: [\n                    {\n                        loader: 'html-loader',\n                        options: {\n                            esModule: false\n                        }\n                    }\n                ]\n            }\n        ]\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksky521%2Fhulk-markdown-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksky521%2Fhulk-markdown-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksky521%2Fhulk-markdown-loader/lists"}