markdowlit
Markdow/CommoMarklitigadstylecheckigforVisualStudioCode
ItroTheMarkdowmarkuplaguageisdesigedtobeeasytoread,write,aduderstad.Itsucceeds-aditsflexibilityisbothabeefitadadrawback.Maystylesarepossible,soformattigcabeicosistet.Somecostructsdo'tworkwelliallparsersadshouldbeavoided.Forexample,herearesomecommo/troublesomeMarkdowcostructs.
markdowlitisaVisualStudioCodeextesiothaticludesalibraryofrulestoecouragestadardsadcosistecyforMarkdowfiles.ItispoweredbymarkdowlitforNode.jswhichisbasedomarkdowlitforRuby.
IstallOpeVisualStudioCodePressCtrl+P/⌘PtoopetheQuickOpedialogTypeextistallmarkdowlittofidtheextesioClicktheIstallbutto,thetheEablebuttoOR
PressCtrl+Shift+X/⇧⌘XtoopetheExtesiostabTypemarkdowlittofidtheextesioClicktheIstallbutto,thetheEablebuttoOR
Opeacommad-liepromptRucode--istall-extesioDavidAso.vscode-markdowlitUseWheeditigaMarkdowfileiCodewithmarkdowlitistalled,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-CodefecestyleSeemarkdowlit'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-ewlieAllviolatiosoftheaboverulesithecurretdocumetcabefixedatocebyruigthemarkdowlit.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.cofigThedefaultrulecofiguratiodisablesMD013/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.focusModeBydefault,alllitigissuesareloggedadhighlightedasyoutypeoreditadocumet.Thisicludes"trasiet"issueslikeMD009/o-trailig-spacessuchaswhetypigattheedofalie.
Ifyoufidthisdistractig,litigcabecofiguredtoigoreissuesothesamelieasthecursor.ThislookslikethefollowigiCode'susersettigs:
{"editor.someSettig":true,"markdowlit.focusMode":true}markdowlit.ruBydefault,litigisperformedasyoutypeoreditadocumet.Litigisfastadefficietadshouldotiterferewithtypicalworkflows.
Ifyoufidthisdistractig,litigcabecofiguredtoruolywhethedocumetissaved.ThislookslikethefollowigiCode'susersettigs:
{"editor.someSettig":true,"markdowlit.ru":"oSave"}Note:WhecofiguredtoruoSave,thelistofreportedissueswillbecomeoutdatedwhilethedocumetiseditedadwillupdatewhethedocumetissaved.
markdowlit.igoreIfaworkspacecotaisgeeratedcotetorotherMarkdowfilesthattriggerwarigsbutcaotbefixed,itmaybehelpfultoigore(skip)thosefileswhelitig.Thiscabedoebycreatigafileamed.markdowlitigoreitherootoftheprojectorbyupdatigtheuser/workspacecofiguratio'smarkdowlit.igoresettigwithaarrayofglobexpressiosmatchigtherelevatfileames.Alteratively,themarkdowlit.igoresettigcabeastrigidetifyigafiletouseisteadof.markdowlitigore.
Wheusiga.markdowlitigorefile(oroverridigit),thecotetofthefilefollowstherulesforgitigoreadmaylooksomethiglike:
#IgoreMarkdowfilesithetestdirectorytest/*.md!test/except/this/oe.mdAexampleofusigCode'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.customRulesCustomrulescabespecifiediCode'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}.
SuppressIdividualwarigscabesuppressedwithcommetsitheMarkdowfileitself:










评论