在Colab中是否可以用Markdown替换表单标题?

huangapple go评论53阅读模式
英文:

Is it possible to replace form headers with Markdown in Colab?

问题

尽管我对Colab笔记本还很陌生,但我无法在任何地方找到这个答案。

我们知道Colab支持Markdown。但是,直接将输入作为表单映射到代码后面,似乎没有办法将表单字段变得更美观成Markdown。

例如,在这个演示表单中

在Colab中是否可以用Markdown替换表单标题?

我想将"text_and_dropdown"显示为"Text and Dropdown"。

我该如何完成这个任务?

英文:

Although I'm new to Colab notebooks, I can't find the answer to this anywhere.

We know that Colab supports Markdown. But, accepting input as a form directly maps to the code-behind with seemingly no way to beautify the form fields into Markdown.

For example, in this demo form:

在Colab中是否可以用Markdown替换表单标题?

I want to show "text_and_dropdown" as so: "Text and Dropdown".

How can I accomplish this?

答案1

得分: 2

我不相信可以使用colab内置表单自定义标签的方式。但我有一个供您考虑的解决方法:

#@title 字符串字段

#@markdown 文本
value = 'value' #@param {namelabel: "hihi",type:"string"}
text = value
#@markdown 下拉框
value = '1st option' #@param ["1st option", "2nd option", "3rd option"]
dropdown = value
#@markdown 文本和下拉框
value = 'value' #@param ["1st option", "2nd option", "3rd option"] {allow-input: true}
text_and_dropdown = value

print(text)
print(dropdown)
print(text_and_dropdown)

这个示例在Markdown中使用了漂亮的部分标题,并使用了一个通用的名称value,没有空格,以使其不太像代码。

您当然可以将value替换为answer或任何您想要的单词标签。如果您想要非常有创意,甚至可以在Python 3中使用Unicode,比如ᐅ = 'value' #@param。我将把决定这个想法是好是坏留给您。

英文:

I don't believe there is a way to customize the label with colab's built-in forms. But I have a workaround for you to consider:

#@title String fields

#@markdown Text
value = 'value' #@param {namelabel: "hihi",type:"string"}
text = value
#@markdown Dropdown
value = '1st option' #@param ["1st option", "2nd option", "3rd option"]
dropdown = value
#@markdown Text and dropdown
value = 'value' #@param ["1st option", "2nd option", "3rd option"] {allow-input: true}
text_and_dropdown = value

print(text)
print(dropdown)
print(text_and_dropdown)

Which uses a nice section header in markdown, and a generic name value with no space to make it not look too much like code.

在Colab中是否可以用Markdown替换表单标题?

You can of course replace value with answer or whatever one-word label you want. If you want to be really creative you can even use unicode in Python 3, like ᐅ = 'value' #@param. I'll leave it up to you to decide whether this idea is good, terrible, or evil.

huangapple
  • 本文由 发表于 2023年2月24日 16:05:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75553988.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定