@@ -892,6 +892,21 @@ def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None
892892 if not handled :
893893 return None , None , None
894894
895+ # If candidate data contains placeholder string - attempt to expand it
896+ # in a limited way - only going 1 level deep.
897+ if str (util .INLINE_PLACEHOLDER_PREFIX ) in id :
898+ inline_processor_index = self .md .treeprocessors .get_index_for_name ('inline' )
899+
900+ ex_m = util .INLINE_PLACEHOLDER_RE .search (id )
901+ while ex_m and ex_m .group (1 ) in self .md .treeprocessors [inline_processor_index ].stashed_nodes :
902+ value = self .md .treeprocessors [inline_processor_index ].stashed_nodes .get (ex_m .group (1 ))
903+ if isinstance (value , str ):
904+ id = id .replace (ex_m .group (0 ), value )
905+ else :
906+ # An `etree` Element - return rendered version only
907+ id = id .replace (ex_m .group (0 ), '' .join (etree .tostring (value , encoding = 'unicode' )))
908+ ex_m = util .INLINE_PLACEHOLDER_RE .search (id )
909+
895910 # Clean up line breaks in id
896911 id = self .NEWLINE_CLEANUP_RE .sub (' ' , id )
897912 if id not in self .md .references : # ignore undefined refs
@@ -911,10 +926,10 @@ def evalId(self, data: str, index: int, text: str) -> tuple[str | None, int, boo
911926 if not m :
912927 return None , index , False
913928 else :
914- id = m .group (1 ). lower ()
929+ id = m .group (1 )
915930 end = m .end (0 )
916931 if not id :
917- id = text . lower ()
932+ id = text
918933 return id , end , True
919934
920935 def makeTag (self , href : str , title : str , text : str ) -> etree .Element :
@@ -925,7 +940,19 @@ def makeTag(self, href: str, title: str, text: str) -> etree.Element:
925940 if title :
926941 el .set ('title' , title )
927942
943+ #if '`' in text: # Process possible backtick within text
944+ # m = self.RE_BACKTICK.search(text)
945+ # if m and m.group(3):
946+ # el2 = etree.Element('code')
947+ # el2.text = util.AtomicString(util.code_escape(m.group(3).strip()))
948+ # el.append(el2)
949+ # el.text = text[0:m.start(0)]
950+ # el2.tail = text[m.end(0):]
951+ # else:
952+ # el.text = text
953+ #else:
928954 el .text = text
955+
929956 return el
930957
931958
@@ -934,7 +961,7 @@ class ShortReferenceInlineProcessor(ReferenceInlineProcessor):
934961 def evalId (self , data : str , index : int , text : str ) -> tuple [str , int , bool ]:
935962 """Evaluate the id of `[ref]`. """
936963
937- return text . lower () , index , True
964+ return text , index , True
938965
939966
940967class ImageReferenceInlineProcessor (ReferenceInlineProcessor ):
0 commit comments