"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["4775"],{7341:function(e,t,n){n.r(t),n.d(t,{default:()=>u,frontMatter:()=>a,metadata:()=>s,assets:()=>c,toc:()=>d,contentTitle:()=>l});var s=JSON.parse('{"id":"languages/fennel","title":"Fennel","description":"Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax and macro system.","source":"@site/docs/languages/fennel.mdx","sourceDirName":"languages","slug":"/languages/fennel","permalink":"/docs/languages/fennel","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/languages/fennel.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"Eta","permalink":"/docs/languages/eta"},"next":{"title":"Flow","permalink":"/docs/languages/flow"}}'),i=n("5893"),r=n("65"),o=n("3365");let a={},l="Fennel",c={},d=[{value:"Usage",id:"usage",level:2},{value:"Language Info",id:"language-info",level:2},{value:"Name",id:"name",level:3},{value:"Extension",id:"extension",level:3},{value:"Editor",id:"editor",level:3},{value:"Compiler",id:"compiler",level:2},{value:"Version",id:"version",level:3},{value:"Code Formatting",id:"code-formatting",level:2},{value:"Starter Template",id:"starter-template",level:2},{value:"Links",id:"links",level:2}];function h(e){let t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",ul:"ul",...(0,r.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"fennel",children:"Fennel"})}),"\n",(0,i.jsxs)(t.p,{children:[(0,i.jsx)(t.a,{href:"https://fennel-lang.org/",children:"Fennel"})," is a programming language that brings together the speed, simplicity, and reach of ",(0,i.jsx)(t.a,{href:"https://www.lua.org/",children:"Lua"})," with the flexibility of a ",(0,i.jsx)(t.a,{href:"https://en.wikipedia.org/wiki/Lisp_(programming_language)",children:"lisp syntax and macro system"}),"."]}),"\n",(0,i.jsxs)(t.p,{children:["Fennel code is compiled to Lua, which then runs in the browser using ",(0,i.jsx)(t.a,{href:"https://fengari.io/",children:"Fengari"}),". See documentation for Lua language support in LiveCodes ",(0,i.jsx)(t.a,{href:"/docs/languages/lua",children:"here"}),"."]}),"\n",(0,i.jsx)(t.admonition,{title:"Note",type:"info",children:(0,i.jsxs)(t.p,{children:["Lisp language family supported in LiveCodes includes ",(0,i.jsx)(t.a,{href:"/docs/languages/commonlisp",children:"Common Lisp"}),", ",(0,i.jsx)(t.a,{href:"/docs/languages/scheme",children:"Scheme"}),", ",(0,i.jsx)(t.a,{href:"/docs/languages/clojurescript",children:"ClojureScript"})," and ",(0,i.jsx)(t.a,{href:"/docs/languages/fennel",children:"Fennel"}),"."]})}),"\n",(0,i.jsx)(t.h2,{id:"usage",children:"Usage"}),"\n",(0,i.jsxs)(t.p,{children:["JavaScript interoperability and DOM access is achieved using ",(0,i.jsxs)(t.a,{href:"https://github.com/fengari-lua/fengari-interop",children:[(0,i.jsx)(t.code,{children:'"js"'})," module"]}),"."]}),"\n","\n",(0,i.jsx)(t.p,{children:"This example demonstrates usage, JavaScript interoperability and DOM access:"}),"\n",(0,i.jsx)(o.Z,{template:"fennel",height:"80vh"}),"\n",(0,i.jsx)(t.h2,{id:"language-info",children:"Language Info"}),"\n",(0,i.jsx)(t.h3,{id:"name",children:"Name"}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.code,{children:"fennel"})}),"\n",(0,i.jsx)(t.h3,{id:"extension",children:"Extension"}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.code,{children:".fnl"})}),"\n",(0,i.jsx)(t.h3,{id:"editor",children:"Editor"}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.code,{children:"script"})}),"\n",(0,i.jsx)(t.h2,{id:"compiler",children:"Compiler"}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.a,{href:"https://fennel-lang.org/",children:"Fennel"})}),"\n",(0,i.jsx)(t.h3,{id:"version",children:"Version"}),"\n",(0,i.jsx)(t.p,{children:"Fennel v1.3.0"}),"\n",(0,i.jsx)(t.h2,{id:"code-formatting",children:"Code Formatting"}),"\n",(0,i.jsxs)(t.p,{children:["Using ",(0,i.jsx)(t.a,{href:"https://shaunlebron.github.io/parinfer/",children:"Parinfer"}),"."]}),"\n",(0,i.jsx)(t.h2,{id:"starter-template",children:"Starter Template"}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.a,{href:"https://livecodes.io/?template=fennel",children:"https://livecodes.io/?template=fennel"})}),"\n",(0,i.jsx)(t.h2,{id:"links",children:"Links"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"https://fennel-lang.org/",children:"Fennel"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"https://fennel-lang.org/tutorial",children:"Fennel tutorial"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"https://www.lua.org/",children:"Lua"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"https://fengari.io/",children:"Fengari"})}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.a,{href:"/docs/languages/lua",children:"lua"})," in LiveCodes"]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.a,{href:"/docs/languages/commonlisp",children:"Common Lisp"})," in LiveCodes"]}),"\n"]})]})}function u(e={}){let{wrapper:t}={...(0,r.a)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},3365:function(e,t,n){n.d(t,{Z:()=>m});var s=n("5893"),i=n("4200"),r=n("7294"),o=n("8294");function a(e){let t=(0,r.useRef)(null),[n,i]=(0,r.useState)(e.className||""),[a,l]=(0,r.useState)(e.style||{}),[c,d]=(0,r.useState)(e.height),[h,u]=(0,r.useState)(),[g,p]=(0,r.useState)(JSON.stringify(e.config||"")),[f,m]=(0,r.useState)("");return(0,r.useEffect)(()=>{if(!t.current)return;let{className:n,style:s,height:r,sdkReady:a,config:c,...v}=e;if(i(n||""),l(s||{}),d(r),h&&f===JSON.stringify(v)){if(g===JSON.stringify(c))return;p(JSON.stringify(c)),"string"==typeof c?fetch(c).then(e=>e.json()).then(e=>{h?.setConfig(e)}):c&&h.setConfig(c)}else m(JSON.stringify(v)),h?.destroy(),(0,o.T)(t.current,{config:c,...v}).then(e=>{u(e),"function"==typeof a&&a(e)})},[e]),(0,r.useEffect)(()=>()=>{h?.destroy()},[]),(0,s.jsx)("div",{ref:t,className:n,style:a,"data-height":c})}var l=n("1858"),c=n("3262"),d=n("1705"),h=n("7645"),u=n("8168"),g=n("8228"),p=n("5050");function f(e){let[t,n]=(0,r.useState)(e.js),[i,o]=(0,r.useState)(e.ts),[a,l]=(0,r.useState)(e.react),[f,m]=(0,r.useState)(e.vue),[v,y]=(0,r.useState)(e.svelte),x="3.7rem",[j,w]=(0,r.useState)(!0),[b,S]=(0,r.useState)(x),C=(0,r.useRef)(null),L=()=>{setTimeout(()=>{S(`calc(${C.current.offsetHeight}px + ${x})`)},5),setTimeout(()=>{S(`calc(${C.current.offsetHeight}px + ${x})`)},255)};return(0,r.useEffect)(()=>{if(c.Z.canUseDOM){let e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"js";try{return window.prettier?.format(e,{parser:"html"===t?"html":"babel",plugins:window.prettierPlugins})}catch{return e}};n(e(t,"js")),o(e(i,"ts")),l(e(a,"jsx")),m(e(f,"html")),y(e(v,"html"))}},[]),(0,s.jsxs)("details",{className:`alert alert--info ${p.Z.details} ${g.Z.details}`,"data-collapsed":j,style:{height:j?x:b,overflow:"hidden",willChange:"height",transition:`height ${j?"250ms":"265ms"} ease-in-out 0s`,margin:"1em 0"},children:[(0,s.jsx)("summary",{onClick:()=>{w(!j),L()},children:"show code"}),(0,s.jsx)("div",{ref:C,style:{display:"block",overflow:"hidden"},children:(0,s.jsx)("div",{className:p.Z.collapsibleContent,children:(0,s.jsxs)(u.Z,{groupId:"sdk-code",children:[(0,s.jsx)(h.Z,{value:"js",label:"JS",attributes:{onMouseDown:L},children:(0,s.jsx)(d.Z,{language:"js",children:t})}),(0,s.jsx)(h.Z,{value:"ts",label:"TS",attributes:{onMouseDown:L},children:(0,s.jsx)(d.Z,{language:"ts",children:i})}),(0,s.jsx)(h.Z,{value:"react",label:"React",attributes:{onMouseDown:L},children:(0,s.jsx)(d.Z,{language:"jsx",children:a})}),(0,s.jsx)(h.Z,{value:"vue",label:"Vue",attributes:{onMouseDown:L},children:(0,s.jsx)(d.Z,{language:"html",children:f})}),(0,s.jsx)(h.Z,{value:"svelte",label:"Svelte",attributes:{onMouseDown:L},children:(0,s.jsx)(d.Z,{language:"html",children:v})})]})})})]})}function m(e){let{className:t,style:n,showCode:r,height:o,...c}=e,{colorMode:d}=(0,i.I)(),h=e=>JSON.stringify(e,null,2),u=`
import { createPlayground } from 'livecodes';
const options = ${h(c)};
createPlayground('#container', options);
`.trimStart(),g=`
import { createPlayground, type EmbedOptions } from 'livecodes';
const options: EmbedOptions = ${h(c)};
createPlayground('#container', options);
`.trimStart(),p=`
import LiveCodes from 'livecodes/react';
export default function App() {
const options = ${h(c)};
return (