テキスト ボックスまたはテキスト編集ボックスのハイパーリンク?テキスト ボックスまたはテキスト編集ボックスにハイパーリンクを挿入する方法はありますか?式列タイプを使用して JMP テーブルでこれを実行できること、およびハイパーリンクのように機能するボタン ボックスをウィンドウ内に作成できることはわかっています。テキスト ボックスの << マークアップ構文も知っていますが、太字、下線、斜体しか使用できません。
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?とてもクールなアプローチ@ih
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?組み合わせる@バイロン_JMPの Web Browser Box のアイデアでは、正規表現文字列を使用して、リンクが埋め込まれた書式設定された HTML ファイルを保存し、それをウィンドウに表示できます。突然、テキストの書式設定を大幅に制御できるようになりました。ユーザーがオプションで [JMP Website] のようなリンク構文にフレンドリ名を追加できるようにすることもできます。 http://www.jmp.com 、いくつかのマークアップ構文に似ています。

Names Default To Here( 1 );
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"[A Link]http://www.reference.md/files/D010/mD010489.html As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *http://www.ncbi.nlm.nih.gov/pubmed/12530994";
t = text;
//wrap links in a string with <A href="https://community.jmp.com/" target="_blank"> tags
findlinks = function({t, recct=0}, {url_regex, rgxmatch = {}, rtn=""},
recct++;
if(recct > 100,
throw("Recursion to deep: " || char(recct) || " levels. Still need to parse: '" || t || "'"));
url_regex = "^(.*?)(\!\[(.+)\])?((https?://){0,}(\w+\.){2,}\w+/?(\w+/?){0,}(\.\w+){0,1}/?)(\b.*)$";
rgxmatch = Regex Match(t, url_regex);
if( N Items(rgxmatch) == 0,
rtn = t, //No link
if( N Items(rgxmatch) == 10, //found a link
rtn = rgxmatch[2] ||
"</A><A href="" || rgxmatch[5] || "" target="_blank" rel="nofollow noopener noreferrer">" || if(is missing(rgxmatch[4]), rgxmatch[5], rgxmatch[4] ) || "</A>" ||
findlinks(rgxmatch[10], recct),
throw("Error matching regex in: '" || t || "'")
)
);
return(rtn)
);
//Create a simple html page from a block of text, save it to the temp files, and return the filename
texttohtmlfile = function({t},
Save text file("$TEMP/Temp HTML file.html", "" || findlinks(t) || "")
);
//Make a temp html file
fn = texttohtmlfile(text);
//Simple window to display html file, deletes the temp file when it closes
w = New Window("Example",wb = Web Browser Box());
w << On Close( Delete File( fn ) );
wb << Set Size(1000, 200);
wb << Set Auto Stretching( 1, 1 );
wb << Set Max Size( 1000, 1000 );
//Show the html file in the window
wb << Navigate( fn );「\[」が「エスケープ文字」セクションを開始するため、正規表現一致表現内の残念なスラッシュバンに注意してください。
スクリーンショットを追加して編集し、タイプミスを修正しました。
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?マークさん、ご提案ありがとうございます。ただし、ユーザーが URL のタグを埋め込まなくて済むようにしたいと考えています。私の上司は、非常にうまく機能する正規表現を考え出しました。
// Sample text
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"http://www.reference.md/files/D010/mD010489.html As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *http://www.ncbi.nlm.nih.gov/pubmed/12530994";
url_regex = "\b(https?://){0,}(\w+\.){2,}\w+/?(\w+/?){0,}(\.\w+){0,1}/?\b";
text_list = {};
link_list = {};
keep_going = 1;
istart = 1;
text_len = length(text);
i = 0;
while(keep_going,
new_text = substr(text, istart);
link_text = regex(new_text, url_regex);
if (!is missing(link_text),
// then
i++;
start_pos = contains(text, link_text, istart);
text_list[i] = substr(text, istart, (start_pos - istart - 1));
link_list[i] = link_text;
istart = start_pos + length(link_text);
,
// else no link found
i++;
text_list[i] = new_text;
keep_going = 0;
);
);
tb = {};
lb = {};
nt = nitems(text_list);
nw = new window("Test link",
vb = vlistbox(
)
);
for(i = 1, i <= nt, i++,
tb[i] = text box(text_list[i], << set width(400));
vb << append(tb[i]);
if (i < nt,
one_button = evalinsert("\[lb[i] = button box("^link_list[i]^", web("^link_list[i]^"), << underline style(1) )]\");
eval(parse(one_button));
vb << append(lb[i]);
);
);
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?Regex() 関数を参照してください。 役に立つかもしれません。 正規表現は非常に単純になります。
Names Default to Here( 1 );
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"<L>http://www.reference.md/files/D010/mD010489.html</L> As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *<L>http://www.ncbi.nlm.nih.gov/pubmed/12530994</L>";
Regex( text,
"<L>(.+?)</L>",
"\1"
);
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?これまでコメントやご提案をいただきありがとうございます。ユーザーのコメント内の URL がどこにあるのかを知る余裕はありません。
出力例を次に示します。

以下にサンプルコードを示します。URL の「マーカー」 と を使用して簡単にしました。これらのマーカーを使用する必要がないように、正規表現を使用して URL の場所をいじってみました。URL を検索するための適切な正規表現を持っている人がいたら、教えてください。これまでネットで見つけたものでさまざまな成功を収めています。
// link markup example
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"<L>http://www.reference.md/files/D010/mD010489.html</L> As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *<L>http://www.ncbi.nlm.nih.gov/pubmed/12530994</L>";
text_list = {};
link_list = {};
keep_going = 1;
istart = 1;
linkstart = "<L>";
linkend = "</L>";
text_len = length(text);
i = 0;
while(keep_going,
start_pos = contains(text, linkstart, istart);
if (start_pos,
end_pos = contains(text, linkend, istart);
if (end_pos,
i++;
text_list[i] = substr(text, istart, (start_pos - istart));
link_list[i] = substr(text, start_pos + 3, (end_pos - start_pos - 3));
istart = istart + end_pos - istart + 4;
);
);
if (!start_pos,
i++;
text_list[i] = substr(text, istart);
keep_going = 0;
);
);
tb = {};
lb = {};
nt = nitems(text_list);
nw = new window("Test link",
vb = vlistbox(
)
);
for(i = 1, i <= nt, i++,
tb[i] = text box(text_list[i], << set width(400));
vb << append(tb[i]);
if (i < nt,
one_button = evalinsert("\[lb[i] = button box("^link_list[i]^", web("^link_list[i]^"), << underline style(1) )]\");
eval(parse(one_button));
vb << append(lb[i]);
);
);
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?ああ、そして、mousebox(textBox) を何度も使用できる関数または式にして、テキスト (見つかったリンク) のみが変更されるようにします。
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?この解決策には、もう少し追加の何か、つまり WrapListBox と MouseBox が必要です。
Names Default To Here( 1 );
New Window( "WrapListBox",
Wrap List Box(
TextBox("This is a long comment to be followed by a link "),
MouseBox(TextBox(" <U>http://www.jmp.com</U> ",<<FONT color="">");
web(lnk);
(this<<CHILD></CHILD></FONT>
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?正規表現を使用してハイパーリンク パターンと一致させることができます。
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?HTML リンクのテキスト ボックスの内容を解析し (「//:http」で始まるパターンを見つける)、パターンごとにリンクを含むボタン ボックスをテキスト ボックスに追加することが可能だと思います。解析されます。
ただし、それはかなり複雑になります。 リンクがテキスト内で認識され、クリック可能であれば、さらに良いでしょう。
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?ボックス全体がリンクになっても問題ない場合は、ボタン ボックスを使用できます。
New Window( "Example",
Text box("Text Block 1"),
Button box( "http://www.jmp.com/", Web( "http://www.jmp.com/" ), Underline Style( 1 ) )
)Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?ありがとう、バイロン、素晴らしいスクリプトですね。しかし、それは私が探していたものではありません。具体的には、テキストボックスにリンクを埋め込み、クリックできるようにしたいと考えています。ユーザーはコメントを入力していますが、コメントは長くなり、参照リンクが含まれる場合があります。私はリンクを解析して表示するアプローチに取り組んでいます。
テキストブロック1 (テキストボックス内)
リンク1 (クリック可能なリンクとして)
テキストブロック2 (テキストボックス内)
リンク2 (クリック可能なリンクとして)
テキストブロック3
等
それはおそらくユーザーに受け入れられるでしょう。
Re: テキスト ボックスまたはテキスト エディット ボックスのハイパーリンク?あなたはこれよりも洗練されたものを探していると思いますが...
Names Default To Here( 1 );
New Window( "Example",
hlistbox("1",
wb = Web Browser Box(),
bb=Button Box( "Take Me to JMP",
wb << Navigate( "http://www.jmp.com" );
wb << Set Auto Stretching( 1, 1 );
wb << Set Max Size( 1000, 1000 );
)));