How can I add markup to a link in node links? I am trying to add some markup around the number of comments link in the standard node links. I want to do this so I can theme the number of comments as a little comment bubble and hide the text (possibly only on mobile). 

I can get this far: 

function mytheme_preprocess_links__node(&amp;$variables) {

 if (isset($variables['links']['comment-comments'])) {
    $title = $variables['links']['comment-comments']['text'];
    $count = 7 // need to get the actual count in here.

    $variables['links']['comment-comments']['link']["#title"] = \Drupal::translation()-&gt;formatPlural($count, ''&lt;span class="comment-count"&gt;1&lt;/span&gt; &lt;span class="comment-text"&gt;comment&lt;/span&gt;', '&lt;span class="commment-count"&gt;@count&lt;/span&gt; &lt;span class="comment-text"&gt;comments&lt;/span&gt;');
  }
}


When I dsm the $title variable I can see that the comment count is in there, I just can't figure out how to get it out into the $count variable. Any help?
Unfortunately the object PluralTranslatableMarkup has no method to get the protected value count. The serialization was fixed to provide the count value, see issue https://www.drupal.org/node/2844181, but the class is still missing it's own getArguments() to extend it with the count value. You could file an issue and wait for a fix or use this work around with reflection:

  if ($title instanceof \Drupal\Core\StringTranslation\PluralTranslatableMarkup) {
    $reflection = new ReflectionClass($title);
    $property = $reflection-&gt;getProperty('count');
    $property-&gt;setAccessible(TRUE);
    $count = $property-&gt;getValue($title);
  }