Here again, we do have our remove html markup function
with the parentheses already in.
Here is the input that doesn't work properly.
Note the usage of a backslash in order to escape the single quote,
which otherwise would be seen as a
delimiter around that string.
We can print this out to see whether it contains the right value,
and you see it has the don't in here exactly as in our example.
In order to address this issue,
we need to record which quote character we actually had
and which we need to check for again.
For this we need to change these lines in here.
What we're going to is, we are going to use the quote variable
to store the quote character, you see?
Now quote is either false
or it contains a double quote or a single quote,
and this makes it impressibly true.
Now this does only work when the quote variable is false,
and this is how we start a quoted string.
When we see that very quote again,
we set quote to false,
and this is what should now finally fix
the problem in this html input.
Then we press run.
And now the single quote and the double quote is properly handled,
and what we get is just the text without the html markup.
remove_html_markup関数があります
括弧が付いています
これが正しく機能しない入力です
シングルクォーテーションのエスケープ時は
バックスラッシュに気をつけます
さもないと文字列の周りに
区切り文字として現れます
正しい値かどうか一度出力します
サンプルと同様don'tが出てしまっています
この問題に対処するために
どのクォーテーションを使っていたのか
記録する必要があります
それにはここの行を変更しなければいけません
クォーテーションを記憶するために
変数quoteを使います
今は変数quoteがFalseか
ダブルクォーテーションもしくは
シングルクォーテーションが含まれています
これで簡単にTrueになります
これは変数quoteがFalseの時にだけ機能します
変数quoteの文字列の開始には
変数quoteをもう一度確認して
Falseに設定します
これでこのHTML入力の問題を
修正することができます
ここで実行します
シングルクォーテーションと
ダブルクォーテーションが処理され
HTMLタグのないテキストになりました