vscode-markdownlint开源项目

我要开发同款
匿名用户2021年12月17日
182阅读

技术信息

开源地址
https://gitee.com/mirrors/morjs
授权协议
MIT License

作品详情

markdowlit

Markdow/CommoMarklitigadstylecheckigforVisualStudioCode

Itro

TheMarkdowmarkuplaguageisdesigedtobeeasytoread,write,aduderstad.Itsucceeds-aditsflexibilityisbothabeefitadadrawback.Maystylesarepossible,soformattigcabeicosistet.Somecostructsdo'tworkwelliallparsersadshouldbeavoided.Forexample,herearesomecommo/troublesomeMarkdowcostructs.

markdowlitisaVisualStudioCodeextesiothaticludesalibraryofrulestoecouragestadardsadcosistecyforMarkdowfiles.ItispoweredbymarkdowlitforNode.jswhichisbasedomarkdowlitforRuby.

IstallOpeVisualStudioCodePressCtrl+P/⌘PtoopetheQuickOpedialogTypeextistallmarkdowlittofidtheextesioClicktheIstallbutto,thetheEablebutto

OR

PressCtrl+Shift+X/⇧⌘XtoopetheExtesiostabTypemarkdowlittofidtheextesioClicktheIstallbutto,thetheEablebutto

OR

Opeacommad-liepromptRucode--istall-extesioDavidAso.vscode-markdowlitUse

WheeditigaMarkdowfileiCodewithmarkdowlitistalled,ayliesthatviolateoeofmarkdowlit'srules(seebelow)willtriggeraWarigitheeditor.WarigsareidicatedbyawavygreeuderlieadcaalsobeseebypressigCtrl+Shift+M/⇧⌘MtoopetheErrorsadWarigsdialog.HoverthemousepoiteroveragreelietoseethewarigorpressF8adShift+F8/⇧F8tocyclethroughallthewarigs(markdowlitwarigsallbegiwithMD###).Formoreiformatioaboutamarkdowlitwarig,placethecursoroalieadclickthelightbulbicoorpressCtrl+./⌘.toopethequickfixdialog.Clickigoeofthewarigsithedialogwilldisplaythatrule'shelpetryithedefaultwebbrowser.

Foratutorial,pleaseseeBuildaAmazigMarkdowEditorUsigVisualStudioCodeadPadocbyDaveJohso.

RulesMD001headig-icremet/header-icremet-HeadiglevelsshouldolyicremetbyoelevelatatimeMD002first-headig-h1/first-header-h1-FirstheadigshouldbeatoplevelheadigMD003headig-style/header-style-HeadigstyleMD004ul-style-UorderedliststyleMD005list-idet-IcosistetidetatioforlistitemsatthesamelevelMD006ul-start-left-CosiderstartigbulletedlistsatthebegiigofthelieMD007ul-idet-UorderedlistidetatioMD009o-trailig-spaces-TrailigspacesMD010o-hard-tabs-HardtabsMD011o-reversed-liks-ReversedliksytaxMD012o-multiple-blaks-MultiplecosecutiveblakliesMD013lie-legth-LielegthMD014commads-show-output-DollarsigsusedbeforecommadswithoutshowigoutputMD018o-missig-space-atx-NospaceafterhashoatxstyleheadigMD019o-multiple-space-atx-MultiplespacesafterhashoatxstyleheadigMD020o-missig-space-closed-atx-NospaceisidehashesoclosedatxstyleheadigMD021o-multiple-space-closed-atx-MultiplespacesisidehashesoclosedatxstyleheadigMD022blaks-aroud-headigs/blaks-aroud-headers-HeadigsshouldbesurroudedbyblakliesMD023headig-start-left/header-start-left-HeadigsmuststartatthebegiigofthelieMD024o-duplicate-headig/o-duplicate-header-MultipleheadigswiththesamecotetMD025sigle-title/sigle-h1-MultipletoplevelheadigsithesamedocumetMD026o-trailig-puctuatio-TrailigpuctuatioiheadigMD027o-multiple-space-blockquote-MultiplespacesafterblockquotesymbolMD028o-blaks-blockquote-BlaklieisideblockquoteMD029ol-prefix-OrderedlistitemprefixMD030list-marker-space-SpacesafterlistmarkersMD031blaks-aroud-feces-FecedcodeblocksshouldbesurroudedbyblakliesMD032blaks-aroud-lists-ListsshouldbesurroudedbyblakliesMD033o-ilie-html-IlieHTMLMD034o-bare-urls-BareURLusedMD035hr-style-HorizotalrulestyleMD036o-emphasis-as-headig/o-emphasis-as-header-EmphasisusedisteadofaheadigMD037o-space-i-emphasis-SpacesisideemphasismarkersMD038o-space-i-code-SpacesisidecodespaelemetsMD039o-space-i-liks-SpacesisideliktextMD040feced-code-laguage-FecedcodeblocksshouldhavealaguagespecifiedMD041first-lie-headig/first-lie-h1-FirstlieifileshouldbeatoplevelheadigMD042o-empty-liks-NoemptyliksMD043required-headigs/required-headers-RequiredheadigstructureMD044proper-ames-ProperamesshouldhavethecorrectcapitalizatioMD045o-alt-text-Imagesshouldhavealteratetext(alttext)MD046code-block-style-CodeblockstyleMD047sigle-trailig-ewlie-FilesshouldedwithasigleewliecharacterMD048code-fece-style-Codefecestyle

Seemarkdowlit'sRules.mdfileformoredetails.

Thefollowigrulescabeautomaticallyfixedbymovigthecursortoaruleviolatio(wavyuderliedtext)adtypigCtrl+./⌘.orclickigthelightbulbico.

MD004ul-styleMD005list-idetMD006ul-start-leftMD007ul-idetMD009o-trailig-spacesMD010o-hard-tabsMD011o-reversed-liksMD012o-multiple-blaksMD014commads-show-outputMD018o-missig-space-atxMD019o-multiple-space-atxMD020o-missig-space-closed-atxMD021o-multiple-space-closed-atxMD022blaks-aroud-headigsMD023headig-start-leftMD026o-trailig-puctuatioMD027o-multiple-space-blockquoteMD030list-marker-spaceMD031blaks-aroud-fecesMD032blaks-aroud-listsMD034o-bare-urlsMD037o-space-i-emphasisMD038o-space-i-codeMD039o-space-i-liksMD044proper-amesMD047sigle-trailig-ewlie

Allviolatiosoftheaboverulesithecurretdocumetcabefixedatocebyruigthemarkdowlit.fixAllcommad,eitherfromtheCommadPalette(viaView|CommadPalette...orCtrl+Shift+P/⇧⌘Pthesearchfor"markdowlit")orbybidigthecommadtoakeyboardshortcut.

ToautomaticallyfixtheseviolatioswhesavigaMarkdowdocumet,cofigureVisualStudioCode'seditor.codeActiosOSavesettiglikeso:

"editor.codeActiosOSave":{"source.fixAll.markdowlit":true}

Automatically-appliedfixescaberevertedbyEdit|UdoorCtrl+Z/⌘Z.

TotemporarilydisablelitigofMarkdowdocumets,ruthemarkdowlit.toggleLitigcommad(fromtheCommadPaletteorbybidigittoakeyboardshortcut).Tore-eablelitig,ruthemarkdowlit.toggleLitigcommadagai.

Note:Theeffectsofthemarkdowlit.toggleLitigcommadareresetwheaewworkspaceisopeed;litigdefaultstoeabled.

Cofiguremarkdowlit.cofig

ThedefaultrulecofiguratiodisablesMD013/lie-legthbecausemayfilesicludelieslogerthathecovetioal80characterlimit:

{"MD013":false}

Note:MD002/first-headig-h1adMD006/ul-start-leftarealsodisabledbecausetheyhavebeedeprecatedithemarkdowlitlibrary.

Rulescabeeabled,disabled,adcustomizedbycreatigaJSONfileamed.markdowlit.jsoc/.markdowlit.jsooraYAMLfileamed.markdowlit.yaml/.markdowlit.ymloraJavaScriptfileamed.markdowlit.jsiaydirectoryofaproject.Additioally,optios(whichicluderulesadthigslikemarkdow-itplugisadothersettigs)cabecofiguredbycreatigaJSONfileamed.markdowlit-cli2.jsocoraYAMLfileamed.markdowlit-cli2.yamloraJavaScriptfileamed.markdowlit-cli2.jsiaydirectoryofaproject.Formoreiformatioaboutcofiguratiofileprecedeceadcompleteexamples,seetheCofiguratiosectioofthemarkdowlit-cli2README.md.

Note:Wheofolderisope,cofiguratioadoptiosareloadedfromtheuser'shomedirectory(e.g.,%USERPROFILE%oWidowsor$HOMEomacOS/Liux).

Acustomcofiguratioisoftedefiedbya.markdowlit.jsofileitherootoftheproject:

{"default":true,"MD003":{"style":"atx_closed"},"MD007":{"idet":4},"o-hard-tabs":false}

Toextedaothercofiguratiofile,suchafilecausetheextedspropertytoprovidearelativepath:

{"exteds":"../.markdowlit.jso","o-hard-tabs":true}

Filesreferecedviaextedsdooteedtobepartofthecurretproject(butusuallyare).

RulescaalsobecofiguredusigCode'ssupportforuseradworkspacesettigs.

TheabovecofiguratiomightlooklikethefollowigiCode'susersettigsfile:

{"editor.someSettig":true,"markdowlit.cofig":{"default":true,"MD003":{"style":"atx_closed"},"MD007":{"idet":4},"o-hard-tabs":false}}

Filepathsreferecedbyextedsfromusersettigsareresolvedrelativetotheuser'shomedirectory(e.g.,%USERPROFILE%oWidowsor$HOMEomacOS/Liux).Filepathsreferecedbyextedsfromworkspacesettigsareresolvedrelativetotheworkspacefolder.Filepathsreferecedbyextedsfromwithitheworkspaceareresolvedrelativetothefileitself.

Cofiguratiosourceshavethefollowigprecedece(idecreasigorder):

.markdowlit-cli2.{jsoc,yaml,js}fileithesameorparetdirectory.markdowlit.{jsoc,jso,yaml,yml,js}fileithesameorparetdirectoryVisualStudioCodeuser/workspacesettigsDefaultcofiguratio(seeabove)

Cofiguratiochagessavedtoaylocatiotakeeffectimmediately.Filesreferecedviaextedsareotmoitoredforchages.Iheritedcofiguratiocabeexplicitlydisabled(orre-eabled)iaycofiguratiofile.

Wheaworkspaceisope,ruigthemarkdowlit.opeCofigFilecommad(fromtheCommadPaletteorbybidigittoakeyboardshortcut)willopeaeditorforthe.markdowlit.{jsoc,jso,yaml,yml,js}cofiguratiofileitherootoftheworkspace.Ifoeofthesefilesexist,aew.markdowlit.jsocotaiigthedefaultrulecofiguratiowillbeopeeditheeditorithe"pedigsave"state.

markdowlit.focusMode

Bydefault,alllitigissuesareloggedadhighlightedasyoutypeoreditadocumet.Thisicludes"trasiet"issueslikeMD009/o-trailig-spacessuchaswhetypigattheedofalie.

Ifyoufidthisdistractig,litigcabecofiguredtoigoreissuesothesamelieasthecursor.ThislookslikethefollowigiCode'susersettigs:

{"editor.someSettig":true,"markdowlit.focusMode":true}markdowlit.ru

Bydefault,litigisperformedasyoutypeoreditadocumet.Litigisfastadefficietadshouldotiterferewithtypicalworkflows.

Ifyoufidthisdistractig,litigcabecofiguredtoruolywhethedocumetissaved.ThislookslikethefollowigiCode'susersettigs:

{"editor.someSettig":true,"markdowlit.ru":"oSave"}

Note:WhecofiguredtoruoSave,thelistofreportedissueswillbecomeoutdatedwhilethedocumetiseditedadwillupdatewhethedocumetissaved.

markdowlit.igore

IfaworkspacecotaisgeeratedcotetorotherMarkdowfilesthattriggerwarigsbutcaotbefixed,itmaybehelpfultoigore(skip)thosefileswhelitig.Thiscabedoebycreatigafileamed.markdowlitigoreitherootoftheprojectorbyupdatigtheuser/workspacecofiguratio'smarkdowlit.igoresettigwithaarrayofglobexpressiosmatchigtherelevatfileames.Alteratively,themarkdowlit.igoresettigcabeastrigidetifyigafiletouseisteadof.markdowlitigore.

Wheusiga.markdowlitigorefile(oroverridigit),thecotetofthefilefollowstherulesforgitigoreadmaylooksomethiglike:

#IgoreMarkdowfilesithetestdirectorytest/*.md!test/except/this/oe.md

AexampleofusigCode'sworkspacecofiguratiotoigorefilesbyglobmightbe:

{"editor.someSettig":true,"markdowlit.igore":["igore.md","directory/igore.md","**/igore.md","**/*.md"]}

Ortoigorefilesbyreferecigadifferetfile:

{"editor.someSettig":true,"markdowlit.igore":".gitigore"}

Theglobbiglibraryusedformatchigmarkdowlit.igorearrayvaluesismiimatchwiththedotadocommetoptioseabled.Matchigiscase-sesitiveadpathsareresolvedrelativetotherootoftheworkspace.Thedirectoryseparatoris/,eveoWidows.

Note:Filescaalsobeigored(iawayothertoolswillrecogize)viatheigorespropertyi.markdowlit-cli2.{jsoc,yaml,js}.

markdowlit.customRules

CustomrulescabespecifiediCode'suser/workspacecofiguratiotoapplyadditioallitigbeyodthedefaultsetofrules.CustomrulesarespecifiedbythepathtoaJavaScriptfileortheameoforpathtoapmpackageexportigoeruleoraarrayofrules(examplesofcustomrules).

Pathsaretypicallyrelativetotherootofthecurretworkspace(ortheuser'shomedirectorywheofolderisope)adshouldbegiwith./todifferetiatetherelativepathfromamoduleidetifier.Pathscabeabsoluteadbegiwith/,thoughthisisdiscouragedbecauseitdoesotworkreliablyacrossdifferetmachies.Ifimplemetigcustomrulesiaworkspace,cosidercommittigtherulecodeuderthe.vscodedirectorywhereitwillbeseparatefromotherworkspacecotetadavailabletoeveryoewhocloestherepository.Pathsoftheform{extesio}/patharerelativetothebasedirectoryoftheCodeextesioamedextesio(whichmustalreadybeistalled).Thissytaxallowscustomrulestobeicludedwithiaotherextesio'spackage,thoughthisisdiscouragedbecauseititroducesasubtledepedecyotheotherextesio.

AexampleofCode'sworkspacesettigsforcustomrulesmightlooklikethefollowig:

{"editor.someSettig":true,"markdowlit.customRules":["./.vscode/my-custom-rule.js","./.vscode/my-custom-rule-array.js","./.vscode/pm-package-for-custom-rule","/absolute/path/to/custom/rule.js","{publisher.extesio-ame}/custom-rule.js","{publisher.extesio-ame}/pm/rule/package"]}

Foriformatioaboutauthorigcustomrules,seethemarkdowlitdocumetatioforcustomrules.

Note:Customrulescaalsobespecified(iawayothertoolswillrecogize)viathecustomRulespropertyi.markdowlit-cli2.{jsoc,yaml,js}.

Suppress

IdividualwarigscabesuppressedwithcommetsitheMarkdowfileitself:

功能介绍

markdownlint Markdown/CommonMark linting and style checking for Visual Studio Code Intro The Mark...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论