Open briandk opened 9 years ago
Wil suggests that we could also think about a two-pass solution that expands reference-style links into inline links. So, suppose you have:
[some text][ref1]
[ref1]: https://github.com
On pass one, the reference links get parsed and added to a dictionary.
On pass two, all reference links are expanded out to inline links. So, the above text becomes:
[some text](https://github.com)
On pass 3 (if necessary) inline links are converted IMG elements (or whatever the media is)
So, suppose we're going to implement a two-pass solution for parsing the source text, and further suppose that solution goes as follows
Pass 1
Pass 2
transcript
data object and slug in the values for accompanying media references by looking each key up in the dictionary objectAdding unique keys to the dictionary
@Wildoane suggests that an easy way to add a key iff it's unique is to first check whether the dictionary has it using
hasOwnProperty
, like so: