@@ -42,6 +42,35 @@ const namedHeaders = function ({ghostVersion} = {}) {
4242    } ; 
4343} ; 
4444
45+ const  fenceLineNumbers  =  function  ( md )  { 
46+     const  proxy  =  ( tokens ,  idx ,  options ,  env ,  self )  =>  self . renderToken ( tokens ,  idx ,  options ) ; 
47+     const  defaultFence  =  md . renderer . rules . fence  ||  proxy ; 
48+ 
49+     // Originally from https://github.com/coreyasmith/markdown-it-fence-line-numbers 
50+     md . renderer . rules . fence  =  function  ( tokens ,  idx ,  options ,  env ,  self )  { 
51+         const  token  =  tokens [ idx ] ; 
52+         const  info  =  token . info ; 
53+         const  attribute  =  'line-numbers' ; 
54+ 
55+         if  ( ! info )  { 
56+             return  defaultFence ( tokens ,  idx ,  options ,  env ,  self ) ; 
57+         } 
58+ 
59+         // line-numbers must come after the first word in the info string to be rendered. 
60+         // Example: ```ruby line-numbers 
61+         // If line-numbers is specified as the first word, fallback to the default behavior 
62+         // (i.e., treat line-numbers as the language). 
63+         const  langAttrs  =  info . split ( / ( \s + ) / g) . slice ( 2 ) . join ( '' ) ; 
64+         const  attributeRegex  =  new  RegExp ( `\\b${ attribute }  ) ; 
65+         if  ( ! langAttrs  ||  ! attributeRegex . test ( langAttrs ) )  { 
66+             return  defaultFence ( tokens ,  idx ,  options ,  env ,  self ) ; 
67+         } 
68+ 
69+         token . attrJoin ( 'class' ,  attribute ) ; 
70+         return  defaultFence ( tokens ,  idx ,  options ,  env ,  self ) ; 
71+     } ; 
72+ } ; 
73+ 
4574const  selectRenderer  =  function  ( options )  { 
4675    const  version  =  semver . coerce ( options . ghostVersion  ||  '4.0' ) ; 
4776
@@ -77,7 +106,8 @@ const selectRenderer = function (options) {
77106            . use ( require ( 'markdown-it-image-lazy-loading' ) ) 
78107            . use ( namedHeaders ( options ) ) 
79108            . use ( require ( 'markdown-it-sub' ) ) 
80-             . use ( require ( 'markdown-it-sup' ) ) ; 
109+             . use ( require ( 'markdown-it-sup' ) ) 
110+             . use ( fenceLineNumbers ) ; 
81111
82112        markdownIt . linkify . set ( { 
83113            fuzzyLink : false 
0 commit comments