001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.html5; 018 019import org.apache.juneau.marshall.*; 020 021/** 022 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/text-level-semantics.html#the-code-element"><code></a> 023 * element. 024 * 025 * <p> 026 * The code element represents a fragment of computer code. It is used to mark up inline code snippets, 027 * variable names, function names, or any other computer code that appears within normal text. The code 028 * element is typically rendered in a monospace font and is commonly used in documentation, tutorials, 029 * and technical writing to distinguish code from regular text. 030 * 031 * <h5 class='section'>Examples:</h5> 032 * <p class='bcode w800'> 033 * <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*; 034 * 035 * <jc>// Simple code snippet</jc> 036 * Code <jv>simple</jv> = <jsm>code</jsm>(<js>"console.log('Hello World');"</js>); 037 * 038 * <jc>// Code with styling</jc> 039 * Code <jv>styled</jv> = <jsm>code</jsm>(<js>"getElementById"</js>) 040 * .class_(<js>"inline-code"</js>); 041 * 042 * <jc>// Code in a sentence</jc> 043 * P <jv>sentence</jv> = <jsm>p</jsm>( 044 * <js>"Use the "</js>, 045 * <jsm>code</jsm>(<js>"print()"</js>), 046 * <js>" function to display output."</js> 047 * ); 048 * 049 * <jc>// Variable name</jc> 050 * Code <jv>variable</jv> = <jsm>code</jsm>(<js>"userName"</js>); 051 * 052 * <jc>// Function call</jc> 053 * Code <jv>function</jv> = <jsm>code</jsm>(<js>"calculateTotal(price, tax)"</js>); 054 * 055 * <jc>// Multiple code elements</jc> 056 * P <jv>multiple</jv> = <jsm>p</jsm>( 057 * <js>"The "</js>, 058 * <jsm>code</jsm>(<js>"if"</js>), 059 * <js>" statement checks the condition, and "</js>, 060 * <jsm>code</jsm>(<js>"else"</js>), 061 * <js>" provides an alternative."</js> 062 * ); 063 * 064 * <jc>// Code with complex content</jc> 065 * Code <jv>complex</jv> = <jsm>code</jsm>( 066 * <js>"const "</js>, 067 * <jsm>strong</jsm>(<js>"result"</js>), 068 * <js>" = "</js>, 069 * <jsm>em</jsm>(<js>"calculate"</js>), 070 * <js>"();"</js> 071 * ); 072 * </p> 073 * 074 * <p> 075 * The following convenience methods are provided for constructing instances of this bean: 076 * <ul class='javatree'> 077 * <li class='jc'>{@link HtmlBuilder} 078 * <ul class='javatree'> 079 * <li class='jm'>{@link HtmlBuilder#code() code()} 080 * <li class='jm'>{@link HtmlBuilder#code(Object...) code(Object...)} 081 * </ul> 082 * </ul> 083 * </p> 084 * 085 * <h5 class='section'>See Also:</h5><ul> 086 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 087 * </ul> 088 */ 089@Marshalled(typeName = "code") 090public class Code extends HtmlElementMixed<Code> { 091 092 /** 093 * Creates an empty {@link Code} element. 094 */ 095 public Code() {} 096 097 /** 098 * Creates a {@link Code} element with the specified child nodes. 099 * 100 * @param children The child nodes. 101 */ 102 public Code(Object...children) { 103 children(children); 104 } 105 106}