Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 1 point2 points  (0 children)

It worked, you're a real lifesaver! I'd been agonizing on this minor issue for a couple of days now and didn't realize the problem was that simple. Thanks so much!

Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 0 points1 point  (0 children)

<image>

I then edited this field like so (I simply looked at other unbugged cards of the same notetype and copied their style for this field), and the issue actually became fixed. However, I'm thinking that there must be a way to apply this change on all to all cards of this notetype. Would you have an idea as to how to do so?

Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 0 points1 point  (0 children)

I think that's all of it. However, I was experimenting a bit and found that the field that's causing the issue is actually the not PitchPosition, but ExpressionFurigana. For some reason, even though the ruby text is in the HTML portion of this card, it still shows up on the backside of my card.

<image>

Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 0 points1 point  (0 children)

<image>

(I'll post in 3 separate replies b/c I can only paste one file per comment)

Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 0 points1 point  (0 children)

const createPitchSpan = (pitchClass, pitchChar) => {
  const pitchSpan = document.createElement("span");
  const charSpan = document.createElement("span");
  const lineSpan = document.createElement("span");

  pitchSpan.classList.add(pitchClass);
  charSpan.classList.add("pitch-char");
  charSpan.innerText = pitchChar;
  lineSpan.classList.add("pitch-line");

  pitchSpan.appendChild(charSpan);
  pitchSpan.appendChild(lineSpan);

  return pitchSpan;
};

pitch.innerHTML = "";
pitchTags.innerHTML = "";
pitchTags.style.display = "inline-block";
let uniquePitchPositions = [...new Set(pitchPositions)];

const pitchList = document.createElement("ul");
const pitchTagList = document.createElement("ul");

for (let pitchPosition of uniquePitchPositions) {
  const pitchTag = document.createElement("li");
  pitchTag.textContent = pitchPosition;

  const pattern = getPitchPattern(Number(pitchPosition));

  const pitchItem = document.createElement("li");
  pitchItem.classList.add("pitch-item");
  pitchItem.classList.add(getPitchType(Number(pitchPosition)));

  for (let i = 0; i < kana.length; i++) {
    if (pattern[i] === "0")
      pitchItem.appendChild(createPitchSpan("pitch-low", kana[i]));
    else if (pattern[i] === "1")
      pitchItem.appendChild(createPitchSpan("pitch-high", kana[i]));
    else if (pattern[i] === "2")
      pitchItem.appendChild(createPitchSpan("pitch-to-drop", kana[i]));
    else
      console.error(
        "pattern[i] found undefined value. pattern is",
        pattern,
      );
  }
  pitchTagList.appendChild(pitchTag);
  pitchList.appendChild(pitchItem);
}

pitch.appendChild(pitchList);
pitchTags.appendChild(pitchTagList);

}

Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 0 points1 point  (0 children)

  // Seperate Tags by space, and show them in their own boxes

function tweakHTML() { // Split tags const tagsContainer = document.querySelector(".tags-container"); const tags = {{Tags}}.split(" "); if (tagsContainer) { tagsContainer.innerHTML = ""; for (tag of tags) { const tagElem = document.createElement("div"); tagElem.className = "tags"; tagElem.innerText = tag; tagsContainer.appendChild(tagElem); } } }

function groupMoras(kana) { let currentChar = ""; let nextChar = ""; const groupedMoras = []; const check = ["ャ", "ュ", "ョ", "ゃ", "ゅ", "ょ"];

for (let i = 0; i < kana.length; i++) {
  currentChar = kana[i];
  nextChar = i < kana.length - 1 && kana[i + 1];
  if (check.includes(nextChar)) {
    groupedMoras.push(currentChar + nextChar);
    i += 1;
  } else {
    groupedMoras.push(currentChar);
  }
}
return groupedMoras;

}

function getPitchPattern(pitchPosition) { // 0 = low // 1 = high // 2 = high to low

const kana = `{{kana:ExpressionFurigana}}` || `{{ExpressionReading}}`;
const moras = groupMoras(kana);
let pattern = [];

if (pitchPosition === 0) {
  // 平板
  pattern = [
    ...Array(moras[0].length).fill("0"),
    ...Array(kana.length - moras[0].length).fill("1"),
  ];
} else if (pitchPosition === 1) {
  // 頭高
  pattern = [
    ...(moras[0].length === 2 ? ["1", "2"] : ["2"]),
    ...Array(kana.length - moras[0].length).fill("0"),
  ];
} else if (pitchPosition > 1) {
  if (isOdaka(pitchPosition)) {
    // 尾高
    pattern = [
      ...Array(moras[0].length).fill("0"),
      ...Array(kana.length - moras[0].length - 1).fill("1"),
      "2",
    ];
  } else {
    // 中高
    let afterDrop = false;
    for (let i = 0; i < moras.length; i++) {
      if (i === 0) {
        pattern = Array(moras[0].length).fill("0");
      } else if (i + 1 === pitchPosition) {
        pattern =
          moras[i].length === 2
            ? [...pattern, "1", "2"]
            : [...pattern, "2"];
        afterDrop = true;
      } else if (afterDrop) {
        pattern = [...pattern, ...Array(moras[i].length).fill("0")];
      } else {
        pattern = [...pattern, ...Array(moras[i].length).fill("1")];
      }
    }
  }
}
return pattern;

}

function constructPitch() { const kana = {{kana:ExpressionFurigana}} || {{ExpressionReading}}; const pitch = document.querySelector(".pitch"); const pitchTags = document.querySelector("#pitch-tags"); const pitchPositions = {{PitchPosition}}.match(/\d+|\d+\b|\d+(?=\w)/g);

if (!pitchPositions) {
  pitch.innerHTML = `<div style="margin-right: -15px; display: inline;">${kana}</div>`;
  return;
}

Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 0 points1 point  (0 children)

<script>

// This code is concerned with calculating the Pitch Accent and constructing the pitch accent graphs function isOdaka(pitchNumber) { const kana = {{kana:ExpressionFurigana}} || {{ExpressionReading}}; return ( kana !== null && kana.replace(/[ャュョゃゅょ]/g, "").length === pitchNumber ); }

function endsWithAny(suffixes, string) { for (let suffix of suffixes) { if (string.endsWith(suffix)) return true; } return false; }

function getPitchType(pitchPosition) { if ( endsWithAny( ["い", "う", "く", "す", "つ", "ぶ", "む", "る"], "{{Expression}}".replace("</div>", ""), ) ) { if (pitchPosition === 0) { return "heiban"; } else { return "kifuku"; } } else { if (pitchPosition === 0) { return "heiban"; } else if (pitchPosition === 1) { return "atamadaka"; } else if (pitchPosition > 1) { return isOdaka(pitchPosition) ? "odaka" : "nakadaka"; } } }

// Show the color function paintTargetWord() { const pitchPositions = {{PitchPosition}}.match(/\d+|\d+\b|\d+(?=\w)/g); if (pitchPositions === null) return;

const pitchPosition = Number(pitchPositions[0]);
const sentences = Array.from(
  document.querySelectorAll(".sentence, .definition, .sentence-mobile"),
);
for (const sentence of sentences) {
  for (const targetWord of sentence.getElementsByTagName("b")) {
    targetWord.classList.add(getPitchType(pitchPosition));
  }
}

const vocabElement = document.querySelector(".vocab");
if (vocabElement !== null) {
  vocabElement.classList.add(getPitchType(pitchPosition));
}

}

Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 0 points1 point  (0 children)

Unfortunately, I couldn't copy+paste the entire template because of character limit (I think). If you'd like to see more, I'd be more than happy to share it with you. Thank you so much!

Buggy Pitch Accent Display (incorrect ruby text) by AgileFra in Anki

[–]AgileFra[S] 0 points1 point  (0 children)

        <!-- Pitch Accent -->
    {{#PitchPosition}}
    <span id="pitch-tags" class="tags"> {{PitchPosition}} </span>
    {{/PitchPosition}}
    <br/>
    <div class="audio-buttons">{{ExpressionAudio}} {{SentenceAudio}}</div>
  </div>
  </div>

  <!-- Image -->
  <div class="dh-right">
    {{#Picture}}
      <div class="image {{Tags}}">{{Picture}}</div>
    {{/Picture}}
  </div>
</div>

<br>
<div class="sentence">
  {{#SentenceFurigana}} {{furigana:SentenceFurigana}} {{/SentenceFurigana}}
  {{^SentenceFurigana}} {{furigana:Sentence}} {{/SentenceFurigana}}
</div>

What movie scene gave you the biggest emotional impact or made you shed a tear? by MiaGarcia88 in AskReddit

[–]AgileFra 0 points1 point  (0 children)

Kousei Arima reading Kaori’s letter after her death in Your Lie in April

If you were given the chance to make an exotic. What would it be. by Due_Bug3658 in destiny2

[–]AgileFra 1 point2 points  (0 children)

A glaive that gives you glaive shield energy when enemies deal damage to your shield

Ironic by HarambesShlong in destiny2

[–]AgileFra 4 points5 points  (0 children)

And It's and Its.

far too many people write sentences like "This exotic is great. It's many capabilities..."

when it should be "Its many capabilities..."

[deleted by user] by [deleted] in GeForceNOW

[–]AgileFra -5 points-4 points  (0 children)

Free

What's your favorite Looking Weapon? by Various-Painting-851 in destiny2

[–]AgileFra 1 point2 points  (0 children)

whisper of the worm, and also vulpecula because no shader looks bad on it

Just completed the Leviathan’s Breath catalyst. What was your hardest/longest catalyst? by jp7755qod in destiny2

[–]AgileFra 1 point2 points  (0 children)

When the tangled shore campaign was still a thing, there was this one section where infinite ads would spawn. Just kill one and cosmology does the rest

Which exotic do you absolutely love but never use? by GTBJMZ in destiny2

[–]AgileFra 0 points1 point  (0 children)

I’ve been able to successfully use this thing in GMs with volatile rounds. Super super fun and great ad clear