@@ -879,6 +879,8 @@ class ReferenceInlineProcessor(LinkInlineProcessor):
879879
880880 RE_LINK = re .compile (r'\s?\[([^\]]*)\]' , re .DOTALL | re .UNICODE )
881881
882+ RE_BACKTICK = re .compile (BACKTICK_RE , re .DOTALL | re .UNICODE )
883+
882884 def handleMatch (self , m : re .Match [str ], data : str ) -> tuple [etree .Element | None , int | None , int | None ]:
883885 """
884886 Return [`Element`][xml.etree.ElementTree.Element] returned by `makeTag` method or `(None, None, None)`.
@@ -892,6 +894,21 @@ def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None
892894 if not handled :
893895 return None , None , None
894896
897+ # If candidate data contains placeholder string - attempt to expand it
898+ # in a limited way - only going 1 level deep.
899+ if str (util .INLINE_PLACEHOLDER_PREFIX ) in id :
900+ inline_processor_index = self .md .treeprocessors .get_index_for_name ('inline' )
901+
902+ ex_m = util .INLINE_PLACEHOLDER_RE .search (id )
903+ while ex_m and ex_m .group (1 ) in self .md .treeprocessors [inline_processor_index ].stashed_nodes :
904+ value = self .md .treeprocessors [inline_processor_index ].stashed_nodes .get (ex_m .group (1 ))
905+ if isinstance (value , str ):
906+ id = id .replace (ex_m .group (0 ), value )
907+ else :
908+ # An `etree` Element - return rendered version only
909+ id = id .replace (ex_m .group (0 ), '' .join (etree .tostring (value , encoding = 'unicode' )))
910+ ex_m = util .INLINE_PLACEHOLDER_RE .search (id )
911+
895912 # Clean up line breaks in id
896913 id = self .NEWLINE_CLEANUP_RE .sub (' ' , id )
897914 if id not in self .md .references : # ignore undefined refs
@@ -911,10 +928,10 @@ def evalId(self, data: str, index: int, text: str) -> tuple[str | None, int, boo
911928 if not m :
912929 return None , index , False
913930 else :
914- id = m .group (1 ). lower ()
931+ id = m .group (1 )
915932 end = m .end (0 )
916933 if not id :
917- id = text . lower ()
934+ id = text
918935 return id , end , True
919936
920937 def makeTag (self , href : str , title : str , text : str ) -> etree .Element :
@@ -925,7 +942,19 @@ def makeTag(self, href: str, title: str, text: str) -> etree.Element:
925942 if title :
926943 el .set ('title' , title )
927944
945+ #if '`' in text: # Process possible backtick within text
946+ # m = self.RE_BACKTICK.search(text)
947+ # if m and m.group(3):
948+ # el2 = etree.Element('code')
949+ # el2.text = util.AtomicString(util.code_escape(m.group(3).strip()))
950+ # el.append(el2)
951+ # el.text = text[0:m.start(0)]
952+ # el2.tail = text[m.end(0):]
953+ # else:
954+ # el.text = text
955+ #else:
928956 el .text = text
957+
929958 return el
930959
931960
@@ -934,7 +963,7 @@ class ShortReferenceInlineProcessor(ReferenceInlineProcessor):
934963 def evalId (self , data : str , index : int , text : str ) -> tuple [str , int , bool ]:
935964 """Evaluate the id of `[ref]`. """
936965
937- return text . lower () , index , True
966+ return text , index , True
938967
939968
940969class ImageReferenceInlineProcessor (ReferenceInlineProcessor ):
0 commit comments