简体   繁体   English

简单形式的Wiki或Markdown式语法?

[英]Wiki or Markdown-like syntax for simple forms?

Is there any simple language similar to Markdown or one of the Wiki Markups that gets converted into HTML form elements? 是否有任何类似于Markdown的简单语言或其中一个转换为HTML表单元素的Wiki标记

For example: 例如:

name* = ___________
sex = (x) Male () Female
phones = [] Android [x] iPhone [] Blackberry
city = {BOS, (SFO), NYC}

Would get converted to: 会转换为:

<label>Name (required):</label><input type="text" name="name" id="name"/>
<label>Sex:</label><input type="radio" name="sex" value="Male" checked="checked"/> <input type="radio" name="sex" value="Female"/>
<label>Phones:</label><input type="check" name="phones" value="Android"/> <input type="check" name="phones" value="iPhone" checked="checked"/> <input type="check" name="phones" value="Blackberry"/>
<label>City:</label> 
<select name="city">
  <option value="BOS">BOS</option>
  <option value="SFO" selected="selected">SFO</option>
  <option value="NYC">NYC</option>
</select>

It would be simple to create one myself, but if any existing library/language supports it already, it would save me some time in implementation, documentation and maintenance. 自己创建一个很简单,但如果现有的库/语言已经支持它,它将节省我一些实施,文档和维护时间。 It would be preferable if the library worked either in Java (so we could run it server-side) or JavaScript (so we could run it client-side). 如果库在Java中运行(因此我们可以在服务器端运行)或JavaScript(因此我们可以在客户端运行它),这将是更好的选择。

Update : I created a github project for this and maleldil implemented it. 更新 :我为此创建了一个github项目 ,并且maleldil实现了它。 Feel free to try it out ! 随意尝试一下

I have not been able to find a library that suits my needs, so I forked the WMD project (which SO uses for its Markdown syntax highlighting) and put the project on on Github . 我找不到适合我需求的库,所以我分叉了WMD项目(SO用于Markdown语法高亮显示)并将项目放在Github上 I didn't have time to implement it, but maleldil kindly did it himself, so try it out ! 我没有时间实施它,但是马尔达尔亲切地亲自做了,所以试试吧

I took a swing at the problem at https://github.com/bradgessler/formdown with a slightly different syntax: 我在https://github.com/bradgessler/formdown上解决了这个问题,但语法略有不同:

Hi _________(Name)

How are you doing today? () Good () Ok () Bad

Could I have your email address? __________@(Email)

Write a few lines that describe your mood: ____________///(Mood)

[ Submit your feelings ]

This is packaged up as the formdown gem and can be used in Rails to render forms via the .fmd file extension (eg app/views/users/edit.fmd.html ). 这被打包为formdown gem,可以在Rails中使用.fmd文件扩展名来呈现表单(例如app/views/users/edit.fmd.html )。

Not an answer. 不是答案。

I think it should read 我认为应该阅读

sex = () Male () Female 性=()男()女

in order to get radio buttons, because 为了获得单选按钮,因为

sex = [] Male [] Female 性别= []男性[]女性

would result in checkboxes (meaning you could be both male and female) 会导致复选框(意味着你可能是男性和女性)

If your going to implement it. 如果你要实现它。 Also, you would hae to require one question per line, so you would know what to group up, otherwise any two () would be linked. 此外,你需要每行一个问题,所以你会知道要分组的内容,否则任何两个()都会被链接。

I also suggest you do not try to put values inside the () or [], since its easier to search for them w/o text inside. 我还建议你不要尝试将值放在()或[]中,因为它更容易在里面搜索文本。 But you might also add ( ) as selected and [ ] as checked. 但是你也可以添加( )为选中,[ ]选中。 If you use that tho, you cant have that stream of characters apear in the questions. 如果你使用那个,你就不能在问题中找到那些字符流。

Just my 2 cents in case your going to implement it. 只需要我的2美分,以防你实施它。

<< GET "/post.php";
    label*: __|n="inputname"|v|p|i|c|l|disabled|readonly; 
    password: *|n|v|p|i|c;
    select: { 'multi word value'= 'Option', 'value2'='Option 2', !'value1'='Option 3' }&|n|i|c;
    (!)|n|v :label for previous radio; ()|n|v :label for previous;
    label for checkboxes: [!]|n|v; []|n|v;
    Message:____|rows|cols|c|p|v;
    File: ^|size||types|i|c
    @submit|v="Send Message";
    @reset|v="Reset Form";
>>
  • << and >> are form start and end signs <<>>是形式的开始和结束标志
  • "this is a label":
  • * immediately after the label is for required fields *标签后立即为必填字段
  • __ is text input __是文本输入
  • | attributes are separated with pipes ( n="name of the field"|c="class of the field" ) 属性用管道分隔( n="name of the field"|c="class of the field"
  • ; is for field separation 用于场分离
  • {} select is much like an associative array. {} select非常类似于关联数组。
  • ! is for checked/selected values 用于选中/选中的值
  • :"label that comes after the value" for radios and checkboxes :"label that comes after the value"对于无线电和复选框, :"label that comes after the value"
  • ____ is textarea ____是textarea
  • ^ caret is for file input (up sign for upload) ^插入符号用于文件输入(上载符号)
  • @submit for buttons @submit为按钮

.. now only if someone implemented this. ..现在只有有人实现了这一点。 :) :)

I am working on a PHP solution that extends Michelf Markdown . 我正在开发一个扩展Michelf Markdown的PHP解决方案。 Currently, basic <input> and <textarea> elements are supported. 目前,支持基本的<input><textarea>元素。 It uses this syntax: 它使用以下语法:

?{type}("label" "value" "placeholder" rows*cols){.class}

Where type can be an input type ( <input type="..." ) or textarea which results in a textarea. type可以是输入类型( <input type="..." )或textarea ,它会产生textarea。

See https://github.com/rbnvrw/markdown-forms for the code and feel free to contribute. 有关代码,请参阅https://github.com/rbnvrw/markdown-forms并随时提供。

i came across http://www.jspwiki.org/Wiki.jsp?page=WikiFormsPlugin some time back. 我在一段时间后遇到了http://www.jspwiki.org/Wiki.jsp?page=WikiFormsPlugin not sure f you can reuse the class tho. 不确定你可以重复使用课程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM