<commit_before>define (require) ->

  settings = require('settings')
  exercisesport = if settings.exercises.port then ":#{settings.exercises.port}" else ''
  exercises = "#{location.protocol}//#{settings.exercises.host}#{exercisesport}"
  renderMath = ($parent) ->
    # We use some invisible spaces as the math markers because they are more reliable than $
    MATH_MARKER_INLINE = '\u200b\u200b\u200b'
    # For the maths.  you know. it do what it do.
    $mathElements = $parent.find('[data-math]:not(.math-rendered)')
    $mathElements.each (iter, element) ->
      formula = element.dataset.math
      element.textContent = "#{MATH_MARKER_INLINE}#{formula}#{MATH_MARKER_INLINE}"
      MathJax?.Hub.Queue(['Typeset', MathJax.Hub], element)
      MathJax?.Hub.Queue ->
        element.classList.add('math-rendered')

  return {
    embeddableTypes: [
      {
        match: '#ost\/api\/ex\/'
        matchType: 'a'
        embeddableType: 'exercise'
        apiUrl: () ->
          "#{exercises}/api/exercises?q=tag:\"#{@itemCode}\""

        # # Adds flexibility for if data needs transformation post API call
        # # For now, not needed for when using actual API.  Comment in if using local stub.
        # filterDataCallback: (data) ->

        #   data.items = _.filter(data.items, (item) ->
        #     _.indexOf(item.tags, @itemCode) > -1
        #   , @)

        onRender: renderMath

        async: true
      },
      {
        match: '#exercises?\/'
        matchType: 'a'
        embeddableType: 'exercise'<commit_msg>Don't escape \ in exercise link regexes<commit_after>define (require) ->

  settings = require('settings')
  exercisesport = if settings.exercises.port then ":#{settings.exercises.port}" else ''
  exercises = "#{location.protocol}//#{settings.exercises.host}#{exercisesport}"
  renderMath = ($parent) ->
    # We use some invisible spaces as the math markers because they are more reliable than $
    MATH_MARKER_INLINE = '\u200b\u200b\u200b'
    # For the maths.  you know. it do what it do.
    $mathElements = $parent.find('[data-math]:not(.math-rendered)')
    $mathElements.each (iter, element) ->
      formula = element.dataset.math
      element.textContent = "#{MATH_MARKER_INLINE}#{formula}#{MATH_MARKER_INLINE}"
      MathJax?.Hub.Queue(['Typeset', MathJax.Hub], element)
      MathJax?.Hub.Queue ->
        element.classList.add('math-rendered')

  return {
    embeddableTypes: [
      {
        match: '#ost/api/ex/'
        matchType: 'a'
        embeddableType: 'exercise'
        apiUrl: () ->
          "#{exercises}/api/exercises?q=tag:\"#{@itemCode}\""

        # # Adds flexibility for if data needs transformation post API call
        # # For now, not needed for when using actual API.  Comment in if using local stub.
        # filterDataCallback: (data) ->

        #   data.items = _.filter(data.items, (item) ->
        #     _.indexOf(item.tags, @itemCode) > -1
        #   , @)

        onRender: renderMath

        async: true
      },
      {
        match: '#exercises?/'
        matchType: 'a'
        embeddableType: 'exercise'
{'fraction_non_alphanumeric': 0.14184397163120568, 'fraction_numerical': 0.006447453255963894, 'mean_word_length': 2.574884792626728, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6187107', 'n_tokens_mistral': 1004, 'n_tokens_neox': 982, 'n_words': 220}